<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="generator" content="VNote">

    <title>2_架构原理</title>
    <link rel="icon" href="https://github.com/tamlok/vnote/raw/master/src/resources/icons/vnote.ico">

    <style type="text/css">
    /* STYLE_GLOBAL_PLACE_HOLDER */
    </style>

    <style type="text/css">
    *,
*::before,
*::after {
  box-sizing: border-box;
}

.container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {
    position: relative;
    width: 100%;
    min-height: 1px;
    padding-right: 15px;
    padding-left: 15px;
}

.col-12 {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 100%;
    flex: 0 0 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .col-md-3 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 25%;
        flex: 0 0 25%;
        max-width: 25%;
    }
}

@media (min-width: 768px) {
    .col-md-9 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 75%;
        flex: 0 0 75%;
        max-width: 75%;
    }
}

@media (min-width: 1200px) {
    .col-xl-2 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 16.666667%;
        flex: 0 0 16.666667%;
        max-width: 16.666667%;
    }
}

@media (min-width: 1200px) {
    .col-xl-10 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 83.333333%;
        flex: 0 0 83.333333%;
        max-width: 83.333333%;
    }
}

@media (min-width: 768px) {
    .pt-md-3, .py-md-3 {
        padding-top: 1rem!important;
    }
}

@media (min-width: 768px) {
    .pb-md-3, .py-md-3 {
        padding-bottom: 1rem!important;
    }
}

@media (min-width: 768px) {
    .pl-md-5, .px-md-5 {
        padding-left: 3rem!important;
    }
}

.d-none {
    display: none!important;
}

@media (min-width: 1200px) {
    .d-xl-block {
        display: block!important;
    }
}

@media (min-width: 768px) {
    .d-md-block {
        display: block!important;
    }
}

.bd-content {
    -webkit-box-ordinal-group: 1;
    -ms-flex-order: 0;
    order: 0;
}

.bd-toc {
    position: -webkit-sticky;
    position: sticky;
    top: 4rem;
    height: calc(100vh - 10rem);
    overflow-y: auto;
}

.bd-toc {
    -webkit-box-ordinal-group: 2;
    -ms-flex-order: 1;
    order: 1;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    font-size: .875rem;
}

.section-nav {
    padding-left: 0;
}

.section-nav ul {
    font-size: .875rem;
    list-style-type: none;
}

.section-nav li {
    font-size: .875rem;
}

.section-nav a {
    color: inherit !important;
}

.row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

@media (min-width: 1200px) {
    .flex-xl-nowrap {
        flex-wrap: nowrap !important;
    }
}

#floating-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #00897B;
    position: fixed;
    top: .5rem;
    right: .5rem;
    cursor: pointer;
    box-shadow: 0px 2px 5px #666;
}

#floating-button .more {
    color: #F5F5F5;
    position: absolute;
    top: 0;
    display: block;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0;
    margin: 0;
    line-height: 2.5rem;
    font-size: 2rem;
    font-family: 'monospace';
    font-weight: 300;
}

.hide-none {
    display: none !important;
}

.col-expand {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-right: 3rem !important;
}

.outline-bold {
    font-weight: bolder !important;
}

@media print {
    #floating-button {
        display: none !important;
    }
}

    @keyframes flash { 
  0% { color: rgb(128, 203, 196); }
  10% { color: rgb(0, 137, 123); }
  40% { color: rgb(0, 137, 123); }
  50% { color: rgb(128, 203, 196); }
  60% { color: rgb(0, 137, 123); }
  90% { color: rgb(0, 137, 123); }
}
.highlighted-anchor { animation: flash 1s; }
div.mark-rect { background: transparent; border: 5px solid rgb(87, 104, 196); border-radius: 2px; position: absolute; }
#vnote-footer { width: 100%; text-align: center; opacity: 0.2; margin-top: 3rem; }
#vnote-footer p { font-size: 0.8rem; }
#vnote-footer a { color: inherit !important; }
x-eqs { display: flex; flex-direction: row; align-content: space-between; align-items: center; }
x-eqs > x-eqn { width: 100%; margin-left: 3rem; }
x-eqs > span { text-align: right; }
.view-image, .view-svg { transition: 0.3s; }
.modal-box { display: none; position: fixed; z-index: 1000; padding-top: 50px; left: 0px; top: 0px; width: 100%; height: 100%; overflow: hidden; background-color: rgba(68, 68, 68, 0.952941); }
.modal-content { margin: auto; display: block; width: auto; height: auto; cursor: move; }
.modal-content { animation-name: zoom; animation-duration: 0.6s; }
@-webkit-keyframes zoom { 
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
@keyframes zoom { 
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
span.modal-close { position: absolute; z-index: 1000; top: 15px; right: 35px; color: rgb(218, 218, 218); font-size: 40px; font-weight: bold; transition: 0.3s; }
span.modal-close:hover, span.modal-close:focus { color: rgb(238, 238, 238); text-decoration: none; cursor: pointer; }
@media print {
  pre, pre code, td.hljs-ln-code { white-space: pre-wrap !important; word-break: break-all !important; }
  code, a { word-break: break-all !important; }
  div.flowchart-diagram, div.mermaid-diagram, div.plantuml-diagram { overflow: hidden !important; }
  img { max-width: 100% !important; height: auto !important; }
  #vnote-footer { display: none !important; }
}
.alert { position: relative; padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; }
.alert-primary { color: rgb(0, 64, 133); background-color: rgb(204, 229, 255); border-color: rgb(184, 218, 255); }
.alert-secondary { color: rgb(56, 61, 65); background-color: rgb(226, 227, 229); border-color: rgb(214, 216, 219); }
.alert-success { color: rgb(21, 87, 36); background-color: rgb(212, 237, 218); border-color: rgb(195, 230, 203); }
.alert-info { color: rgb(12, 84, 96); background-color: rgb(209, 236, 241); border-color: rgb(190, 229, 235); }
.alert-warning { color: rgb(133, 100, 4); background-color: rgb(255, 243, 205); border-color: rgb(255, 238, 186); }
.alert-danger { color: rgb(114, 28, 36); background-color: rgb(248, 215, 218); border-color: rgb(245, 198, 203); }
.alert-light { color: rgb(129, 129, 130); background-color: rgb(254, 254, 254); border-color: rgb(253, 253, 254); }
.alert-dark { color: rgb(27, 30, 33); background-color: rgb(214, 216, 217); border-color: rgb(198, 200, 202); }
.vnote-anchor { font-weight: 400; color: rgba(0, 123, 255, 0.498039); transition: color 0.16s linear; padding-left: 0.375em; -webkit-font-smoothing: antialiased; text-decoration: none; opacity: 0; }
.vnote-anchor:hover { color: rgb(0, 123, 255); text-decoration: none; opacity: 1; }
.vnote-anchor::after { content: attr(data-anchor-icon); }
.vnote-btn { position: relative; display: inline-block; padding: 6px 12px; font-size: 13px; font-weight: 700; line-height: 20px; white-space: nowrap; vertical-align: middle; cursor: pointer; border: none; user-select: none; -webkit-appearance: none; }
.vnote-copy-clipboard-btn { transition: opacity 0.3s ease-in-out; opacity: 0; padding: 2px 6px; position: absolute; top: 5px; right: 5px; }
pre:hover .vnote-copy-clipboard-btn { opacity: 1; }
pre.vnote-snippet { position: relative; }
body { margin: 0px auto; font-family: "Segoe UI", Helvetica, sans-serif, Tahoma, Arial, Geneva, Georgia, Palatino, "Times New Roman", "Hiragino Sans GB", 冬青黑体, "Microsoft YaHei", 微软雅黑, "Microsoft YaHei UI", "WenQuanYi Micro Hei", 文泉驿雅黑, Dengxian, 等线体, STXihei, 华文细黑, "Liberation Sans", "Droid Sans", NSimSun, 新宋体, SimSun, 宋体; color: rgb(34, 34, 34); line-height: 1.5; padding: 15px; background: rgb(238, 238, 238); font-size: 16px; }
h1, h2, h3, h4, h5, h6 { color: rgb(34, 34, 34); font-weight: bold; margin-top: 20px; margin-bottom: 10px; padding: 0px; }
p { padding: 0px; margin-top: 16px; margin-bottom: 16px; }
h1 { font-size: 26px; }
h2 { font-size: 24px; }
h3 { font-size: 22px; }
h4 { font-size: 20px; }
h5 { font-size: 19px; }
h6 { font-size: 18px; }
a { color: rgb(0, 153, 255); margin: 0px; padding: 0px; vertical-align: baseline; text-decoration: none; word-break: break-word; }
a:hover { text-decoration: underline; color: rgb(255, 102, 0); }
a:visited { color: purple; }
ul, ol { padding: 0px 0px 0px 24px; }
li { line-height: 24px; }
li ul, li ol { margin-left: 16px; }
p, ul, ol { font-size: 16px; line-height: 24px; }
pre { display: block; overflow-y: hidden; overflow-x: auto; tab-size: 4; }
code { font-family: Consolas, Monaco, monospace, Courier; color: rgb(142, 36, 170); word-break: break-word; }
pre code { display: block; overflow-x: auto; padding: 0.5em; color: rgb(34, 34, 34); background-color: rgb(224, 224, 224); border-left: 0.5em solid rgb(0, 137, 123); line-height: 1.5; font-family: Consolas, Monaco, monospace, Courier; white-space: pre; tab-size: 4; }
pre code.markdown-metadata { border-left: 0.5em solid rgb(128, 203, 196); }
aside { display: block; float: right; width: 390px; }
blockquote { color: rgb(102, 102, 102); border-left: 0.5em solid rgb(122, 122, 122); padding: 0px 1em; margin-left: 0px; }
blockquote p { color: rgb(102, 102, 102); }
hr { display: block; text-align: left; margin: 1em 0px; border: none; height: 2px; background: rgb(153, 153, 153); }
table { padding: 0px; margin: 1rem 0.5rem; border-collapse: collapse; }
table tr { border-top: 2px solid rgb(204, 204, 204); background-color: white; margin: 0px; padding: 0px; }
table tr:nth-child(2n) { background-color: rgb(248, 248, 248); }
table tr th { font-weight: bold; border: 2px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px; }
table tr td { border: 2px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px; }
table tr th :first-child, table tr td :first-child { margin-top: 0px; }
table tr th :last-child, table tr td :last-child { margin-bottom: 0px; }
div.mermaid-diagram { margin: 16px 0px; overflow-y: hidden; }
div.flowchart-diagram { padding: 0px 5px; margin: 16px 0px; width: fit-content; overflow: hidden; }
div.wavedrom-diagram { padding: 0px 5px; margin: 16px 0px; width: fit-content; overflow: hidden; }
div.plantuml-diagram { padding: 5px 5px 0px; margin: 16px 0px; width: fit-content; overflow: hidden; }
.img-package { text-align: center; }
img.img-center { display: block; margin-left: auto; margin-right: auto; }
span.img-caption { min-width: 20%; max-width: 80%; display: inline-block; padding: 10px; margin: 0px auto; border-bottom: 1px solid rgb(192, 192, 192); color: rgb(108, 108, 108); text-align: center; line-height: 1.5; }
.emoji_zero, .emoji_one, .emoji_two, .emoji_three, .emoji_four, .emoji_five, .emoji_six, .emoji_seven, .emoji_eight, .emoji_nine { margin-left: 5px; margin-right: 8px; }
div.preview-hint { opacity: 0.5; margin-top: 30%; margin-bottom: 30%; align-items: center; display: flex; flex-direction: column; justify-content: center; }
table.hljs-ln tr { border: none; background-color: transparent; }
table.hljs-ln tr td { border: none; background-color: transparent; }
table.hljs-ln tr td.hljs-ln-numbers { user-select: none; text-align: center; color: rgb(170, 170, 170); border-right: 1px solid rgb(204, 204, 204); vertical-align: top; padding-right: 5px; white-space: nowrap; }
table.hljs-ln tr td.hljs-ln-code { padding-left: 10px; }
::-webkit-scrollbar { background-color: rgb(234, 234, 234); width: 14px; height: 14px; border: none; }
::-webkit-scrollbar-corner { background-color: rgb(234, 234, 234); }
::-webkit-scrollbar-button { height: 14px; width: 14px; background-color: rgb(234, 234, 234); }
::-webkit-scrollbar-button:hover { background-color: rgb(208, 208, 208); }
::-webkit-scrollbar-button:active { background-color: rgb(178, 178, 178); }
::-webkit-scrollbar-track { background-color: rgb(234, 234, 234); }
::-webkit-scrollbar-thumb { border: none; background-color: rgb(218, 218, 218); }
::-webkit-scrollbar-thumb:hover { background-color: rgb(208, 208, 208); }
::-webkit-scrollbar-thumb:active { background-color: rgb(178, 178, 178); }
::-webkit-scrollbar-button:horizontal:increment { background-image: url('data:image/svg+xml;utf8,<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g>    <g transform="rotate(-90 256.00000000000006,256) " id="svg_1">   <polygon fill="%23333333" id="svg_2" points="128,192 256,320 384,192  "/>  </g> </g></svg>'); background-repeat: no-repeat; background-size: contain; }
::-webkit-scrollbar-button:horizontal:decrement { background-image: url('data:image/svg+xml;utf8,<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g>    <g transform="rotate(90 255.99999999999997,256.00000000000006) " id="svg_1">   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="%23333333"/>  </g> </g></svg>'); background-repeat: no-repeat; background-size: contain; }
::-webkit-scrollbar-button:vertical:increment { background-image: url('data:image/svg+xml;utf8,<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g>    <g transform="null" id="svg_1">   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="%23333333"/>  </g> </g></svg>'); background-repeat: no-repeat; background-size: contain; }
::-webkit-scrollbar-button:vertical:decrement { background-image: url('data:image/svg+xml;utf8,<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g>    <g transform="rotate(180 255.99999999999997,256) " id="svg_1">   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="%23333333"/>  </g> </g></svg>'); background-repeat: no-repeat; background-size: contain; }
::selection { background: rgb(25, 118, 210); color: rgb(238, 238, 238); }
.modal-box { background-color: rgba(234, 234, 234, 0.952941); }
span.modal-close { color: rgb(102, 102, 102); }
span.modal-close:hover, span.modal-close:focus { color: rgb(34, 34, 34); }
.hljs { display: block; overflow-x: auto; padding: 0.5em; background: rgb(224, 224, 224); }
.hljs, .hljs-subst { color: rgb(54, 54, 54); }
.hljs-comment { color: rgb(118, 118, 118); }
.hljs-keyword, .hljs-attribute, .hljs-selector-tag, .hljs-meta-keyword, .hljs-doctag, .hljs-name { color: rgb(0, 0, 238); }
.hljs-type, .hljs-string, .hljs-number, .hljs-selector-id, .hljs-selector-class, .hljs-quote, .hljs-template-tag, .hljs-deletion { color: rgb(136, 0, 0); }
.hljs-title, .hljs-section { color: rgb(136, 0, 0); font-weight: bold; }
.hljs-regexp, .hljs-symbol, .hljs-variable, .hljs-template-variable, .hljs-link, .hljs-selector-attr, .hljs-selector-pseudo { color: rgb(188, 96, 96); }
.hljs-literal { color: rgb(175, 0, 215); }
.hljs-built_in, .hljs-bullet, .hljs-code, .hljs-addition { color: rgb(0, 135, 0); }
.hljs-meta { color: rgb(31, 113, 153); }
.hljs-meta-string { color: rgb(77, 153, 191); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }
.mermaid-diagram .mermaid .label { color: rgb(51, 51, 51); }
.mermaid-diagram .node rect, .mermaid-diagram .node circle, .mermaid-diagram .node ellipse, .mermaid-diagram .node polygon { fill: rgb(236, 236, 255); stroke: rgb(204, 204, 255); stroke-width: 1px; }
.mermaid-diagram .edgePath .path { stroke: rgb(51, 51, 51); }
.mermaid-diagram .edgeLabel { background-color: rgb(232, 232, 232); }
.mermaid-diagram .cluster rect { fill: rgb(255, 255, 222) !important; rx: 4 !important; stroke: rgb(170, 170, 51) !important; stroke-width: 1px !important; }
.mermaid-diagram .cluster text { fill: rgb(51, 51, 51); }
.mermaid-diagram .actor { stroke: rgb(204, 204, 255); fill: rgb(236, 236, 255); }
.mermaid-diagram text.actor { fill: black; stroke: none; }
.mermaid-diagram .actor-line { stroke: grey; }
.mermaid-diagram .messageLine0 { stroke-width: 1.5; stroke: rgb(51, 51, 51); }
.mermaid-diagram .messageLine1 { stroke-width: 1.5; stroke: rgb(51, 51, 51); }
.mermaid-diagram #arrowhead { fill: rgb(51, 51, 51); }
.mermaid-diagram #crosshead path { fill: rgb(51, 51, 51) !important; stroke: rgb(51, 51, 51) !important; }
.mermaid-diagram .messageText { fill: rgb(51, 51, 51); stroke: none; }
.mermaid-diagram .labelBox { stroke: rgb(204, 204, 255); fill: rgb(236, 236, 255); }
.mermaid-diagram .labelText { fill: black; stroke: none; }
.mermaid-diagram .loopText { fill: black; stroke: none; }
.mermaid-diagram .loopLine { stroke-width: 2; stroke: rgb(204, 204, 255); }
.mermaid-diagram .note { stroke: rgb(170, 170, 51); fill: rgb(255, 245, 173); }
.mermaid-diagram .noteText { fill: black; stroke: none; font-family: "trebuchet ms", verdana, arial; font-size: 14px; }
.mermaid-diagram .section { stroke: none; opacity: 0.2; }
.mermaid-diagram .section0 { fill: rgba(102, 102, 255, 0.490196); }
.mermaid-diagram .section2 { fill: rgb(255, 244, 0); }
.mermaid-diagram .section1, .mermaid-diagram .section3 { fill: white; opacity: 0.2; }
.mermaid-diagram .sectionTitle0 { fill: rgb(51, 51, 51); }
.mermaid-diagram .sectionTitle1 { fill: rgb(51, 51, 51); }
.mermaid-diagram .sectionTitle2 { fill: rgb(51, 51, 51); }
.mermaid-diagram .sectionTitle3 { fill: rgb(51, 51, 51); }
.mermaid-diagram .sectionTitle { text-anchor: start; font-size: 11px; }
.mermaid-diagram .grid .tick { stroke: lightgrey; opacity: 0.3; shape-rendering: crispEdges; }
.mermaid-diagram .grid path { stroke-width: 0; }
.mermaid-diagram .today { fill: none; stroke: red; stroke-width: 2px; }
.mermaid-diagram .task { stroke-width: 2; }
.mermaid-diagram .taskText { text-anchor: middle; font-size: 11px; }
.mermaid-diagram .taskTextOutsideRight { fill: black; text-anchor: start; font-size: 11px; }
.mermaid-diagram .taskTextOutsideLeft { fill: black; text-anchor: end; font-size: 11px; }
.mermaid-diagram .taskText0, .mermaid-diagram .taskText1, .mermaid-diagram .taskText2, .mermaid-diagram .taskText3 { fill: white; }
.mermaid-diagram .task0, .mermaid-diagram .task1, .mermaid-diagram .task2, .mermaid-diagram .task3 { fill: rgb(138, 144, 221); stroke: rgb(83, 79, 188); }
.mermaid-diagram .taskTextOutside0, .mermaid-diagram .taskTextOutside2 { fill: black; }
.mermaid-diagram .taskTextOutside1, .mermaid-diagram .taskTextOutside3 { fill: black; }
.mermaid-diagram .active0, .mermaid-diagram .active1, .mermaid-diagram .active2, .mermaid-diagram .active3 { fill: rgb(191, 199, 255); stroke: rgb(83, 79, 188); }
.mermaid-diagram .activeText0, .mermaid-diagram .activeText1, .mermaid-diagram .activeText2, .mermaid-diagram .activeText3 { fill: black !important; }
.mermaid-diagram .done0, .mermaid-diagram .done1, .mermaid-diagram .done2, .mermaid-diagram .done3 { stroke: grey; fill: lightgrey; stroke-width: 2; }
.mermaid-diagram .doneText0, .mermaid-diagram .doneText1, .mermaid-diagram .doneText2, .mermaid-diagram .doneText3 { fill: black !important; }
.mermaid-diagram .crit0, .mermaid-diagram .crit1, .mermaid-diagram .crit2, .mermaid-diagram .crit3 { stroke: rgb(255, 136, 136); fill: red; stroke-width: 2; }
.mermaid-diagram .activeCrit0, .mermaid-diagram .activeCrit1, .mermaid-diagram .activeCrit2, .mermaid-diagram .activeCrit3 { stroke: rgb(255, 136, 136); fill: rgb(191, 199, 255); stroke-width: 2; }
.mermaid-diagram .doneCrit0, .mermaid-diagram .doneCrit1, .mermaid-diagram .doneCrit2, .mermaid-diagram .doneCrit3 { stroke: rgb(255, 136, 136); fill: lightgrey; stroke-width: 2; cursor: pointer; shape-rendering: crispEdges; }
.mermaid-diagram .doneCritText0, .mermaid-diagram .doneCritText1, .mermaid-diagram .doneCritText2, .mermaid-diagram .doneCritText3 { fill: black !important; }
.mermaid-diagram .activeCritText0, .mermaid-diagram .activeCritText1, .mermaid-diagram .activeCritText2, .mermaid-diagram .activeCritText3 { fill: black !important; }
.mermaid-diagram .titleText { text-anchor: middle; font-size: 18px; fill: black; }
.mermaid-diagram .node text { font-family: "trebuchet ms", verdana, arial; font-size: 14px; }
.mermaid-diagram div.mermaidTooltip { position: absolute; text-align: center; max-width: 200px; padding: 2px; font-family: "trebuchet ms", verdana, arial; font-size: 12px; background: rgb(255, 255, 222); border: 1px solid rgb(170, 170, 51); border-radius: 2px; pointer-events: none; z-index: 100; }
#mermaid-diagram-1 .node > rect { }
#mermaid-diagram-1 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-1 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-1 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-1 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-2 .node > rect { }
#mermaid-diagram-2 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-2 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-2 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-2 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-3 .node > rect { }
#mermaid-diagram-3 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-3 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-3 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-3 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-4 .node > rect { }
#mermaid-diagram-4 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-4 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-4 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-4 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-5 .node > rect { }
#mermaid-diagram-5 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-5 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-5 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-5 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-6 .node > rect { }
#mermaid-diagram-6 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-6 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-6 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-6 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-7 .node > rect { }
#mermaid-diagram-7 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-7 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-7 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-7 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-8 .node > rect { }
#mermaid-diagram-8 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-8 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-8 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-8 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-9 .node > rect { }
#mermaid-diagram-9 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-9 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-9 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-9 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-10 .node > rect { }
#mermaid-diagram-10 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-10 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-10 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-10 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-12 .node > rect { }
#mermaid-diagram-12 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-12 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-12 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-12 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-13 .node > rect { }
#mermaid-diagram-13 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-13 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-13 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-13 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-14 .node > rect { }
#mermaid-diagram-14 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-14 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-14 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-14 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-15 .node > rect { }
#mermaid-diagram-15 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-15 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-15 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-15 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }
#mermaid-diagram-16 .node > rect { }
#mermaid-diagram-16 .node text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-16 .edgeLabel text { fill: rgb(0, 0, 0); stroke: none; font-weight: 300; font-family: "Helvetica Neue", Helvetica, Arial, sans-serf; font-size: 14px; }
#mermaid-diagram-16 .cluster rect { fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-16 .cyan > rect, .cyan > polygon, .cyan > circle, .cyan > ellipse { fill: rgb(153, 255, 255); stroke: rgb(255, 255, 255); }

    </style>

    <script type="text/javascript">
var toc = [];

var setVisible = function(node, visible) {
    var cl = 'hide-none';
    if (visible) {
        node.classList.remove(cl);
    } else {
        node.classList.add(cl);
    }
};

var isVisible = function(node) {
    var cl = 'hide-none';
    return !node.classList.contains(cl);
};

var setPostContentExpanded = function(node, expanded) {
    var cl = 'col-expand';
    if (expanded) {
        node.classList.add(cl);
    } else {
        node.classList.remove(cl);
    }
};

var setOutlinePanelVisible = function(visible) {
    var outlinePanel = document.getElementById('outline-panel');
    var postContent = document.getElementById('post-content');

    setVisible(outlinePanel, visible);
    setPostContentExpanded(postContent, !visible);
};

var isOutlinePanelVisible = function() {
    var outlinePanel = document.getElementById('outline-panel');
    return isVisible(outlinePanel);
};

window.addEventListener('load', function() {
    var outlinePanel = document.getElementById('outline-panel');
    outlinePanel.style.display = 'initial';

    var floatingContainer = document.getElementById('container-floating');
    floatingContainer.style.display = 'initial';

    var outlineContent = document.getElementById('outline-content');
    var postContent = document.getElementById('post-content');

    // Escape @text to Html.
    var escapeHtml = function(text) {
        var map = {
            '&': '&amp;',
            '<': '&lt;',
            '>': '&gt;',
            '"': '&quot;',
            "'": '&#039;'
        };

        return text.replace(/[&<>"']/g, function(m) { return map[m]; });
    }

    // Fetch the outline.
    var headers = postContent.querySelectorAll("h1, h2, h3, h4, h5, h6");
    toc = [];
    for (var i = 0; i < headers.length; ++i) {
        var header = headers[i];

        toc.push({
            level: parseInt(header.tagName.substr(1)),
            anchor: header.id,
            title: escapeHtml(header.textContent)
        });
    }

    if (toc.length == 0) {
        setOutlinePanelVisible(false);
        setVisible(floatingContainer, false);
        return;
    }

    var baseLevel = baseLevelOfToc(toc);
    var tocTree = tocToTree(toPerfectToc(toc, baseLevel), baseLevel);

    outlineContent.innerHTML = tocTree;
    setOutlinePanelVisible(true);
    setVisible(floatingContainer, true);
});

// Return the topest level of @toc, starting from 1.
var baseLevelOfToc = function(p_toc) {
    var level = -1;
    for (i in p_toc) {
        if (level == -1) {
            level = p_toc[i].level;
        } else if (level > p_toc[i].level) {
            level = p_toc[i].level;
        }
    }

    if (level == -1) {
        level = 1;
    }

    return level;
};

// Handle wrong title levels, such as '#' followed by '###'
var toPerfectToc = function(p_toc, p_baseLevel) {
    var i;
    var curLevel = p_baseLevel - 1;
    var perfToc = [];
    for (i in p_toc) {
        var item = p_toc[i];

        // Insert empty header.
        while (item.level > curLevel + 1) {
            curLevel += 1;
            var tmp = { level: curLevel,
                        anchor: '',
                        title: '[EMPTY]'
                      };
            perfToc.push(tmp);
        }

        perfToc.push(item);
        curLevel = item.level;
    }

    return perfToc;
};

var itemToHtml = function(item) {
    return '<a href="#' + item.anchor + '" data="' + item.anchor + '">' + item.title + '</a>';
};

// Turn a perfect toc to a tree using <ul>
var tocToTree = function(p_toc, p_baseLevel) {
    var i;
    var front = '<li>';
    var ending = ['</li>'];
    var curLevel = p_baseLevel;
    for (i in p_toc) {
        var item = p_toc[i];
        if (item.level == curLevel) {
            front += '</li>';
            front += '<li>';
            front += itemToHtml(item);
        } else if (item.level > curLevel) {
            // assert(item.level - curLevel == 1)
            front += '<ul>';
            ending.push('</ul>');
            front += '<li>';
            front += itemToHtml(item);
            ending.push('</li>');
            curLevel = item.level;
        } else {
            while (item.level < curLevel) {
                var ele = ending.pop();
                front += ele;
                if (ele == '</ul>') {
                    curLevel--;
                }
            }
            front += '</li>';
            front += '<li>';
            front += itemToHtml(item);
        }
    }
    while (ending.length > 0) {
        front += ending.pop();
    }
    front = front.replace("<li></li>", "");
    front = '<ul>' + front + '</ul>';
    return front;
};

var toggleMore = function() {
    if (toc.length == 0) {
        return;
    }

    var p = document.getElementById('floating-more');
    if (isOutlinePanelVisible()) {
        p.textContent = '<';
        setOutlinePanelVisible(false);
    } else {
        p.textContent = '>';
        setOutlinePanelVisible(true);
    }
};

window.addEventListener('scroll', function() {
    if (toc.length == 0 || !isOutlinePanelVisible()) {
        return;
    }

    var postContent = document.getElementById('post-content');
    var scrollTop = document.documentElement.scrollTop
                    || document.body.scrollTop
                    || window.pageYOffset;
    var eles = postContent.querySelectorAll("h1, h2, h3, h4, h5, h6");

    if (eles.length == 0) {
        return;
    }

    var idx = -1;
    var biaScrollTop = scrollTop + 50;
    for (var i = 0; i < eles.length; ++i) {
        if (biaScrollTop >= eles[i].offsetTop) {
            idx = i;
        } else {
            break;
        }
    }

    var header = '';
    if (idx != -1) {
        header = eles[idx].id;
    }

    highlightItemOnlyInOutline(header);
});

var highlightItemOnlyInOutline = function(id) {
    var cl = 'outline-bold';
    var outlineContent = document.getElementById('outline-content');
    var eles = outlineContent.querySelectorAll("a");
    var target = null;
    for (var i = 0; i < eles.length; ++i) {
        var ele = eles[i];
        if (ele.getAttribute('data') == id) {
            target = ele;
            ele.classList.add(cl);
        } else {
            ele.classList.remove(cl);
        }
    }

    // TODO: scroll target into view within the outline panel scroll area.
};

</script>


<!-- HEAD_PLACE_HOLDER -->
</head>
<body>
<div class="container-fluid">
<div class="row flex-xl-nowrap">
    <div id="outline-panel" style="display:none;" class="d-none d-md-block d-xl-block col-md-3 col-xl-2 bd-toc">
        <div id="outline-content" class="section-nav"></div>
    </div>
    <div id="post-content" class="col-12 col-md-9 col-xl-10 py-md-3 pl-md-5 bd-content">
    <div style="page-break-after: always;"></div>
<h1 id="toc_0">2. 架构原理<a class="vnote-anchor" href="#toc_0" data-anchor-icon="#"></a></h1>
<p><img src='' alt="" class="view-image"></p>
<p>  这个框架试图实现一些“最佳实践”模式，其中包括：</p>
<ul>
<li>模型视图控制器，详见<a href="">模型视图控制器</a>部分；</li>
<li>多层架构-见下文，详见<a href="">多层架构</a>部分；</li>
<li>测试驱动的设计，详见<a href="">测试和日志</a>部分；</li>
<li>无状态CRUD/REST，详见<a href="">REST</a>部分；</li>
<li>对象关系映射，详见<a href="">对象关系映射（ORM）</a>部分；</li>
<li>对象文档映射，详见<a href="">NoSQL和对象文档映射（ODM）</a>部分；</li>
<li>面向服务的架构，详见<a href="">面向服务的架构（SOA）</a>部分。</li>
</ul>
<p>  所有这些使得各种项目的实现成为可能，一直到复杂的领域驱动设计。</p>
<h2 id="toc_1">2.1. 总体设计<a class="vnote-anchor" href="#toc_1" data-anchor-icon="#"></a></h2>
<p>  mORMot架构的总体设计如下图所示：</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-1" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 2308 1608" style="max-width:2308px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-1 .node&gt;rect { ; }
#mermaid-diagram-1 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-1 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-1 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-1 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"><g class="cluster" id="subGraph4" transform="translate(677.875,986.5)" style="opacity: 1;"><rect width="1315.75" height="879" x="-657.875" y="-439.5"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-425.5" fill="black" stroke="none" id="mermaid-diagram-1Text" style="text-anchor: middle;"> mORMot Server</text></g><g class="cluster" id="subGraph3" transform="translate(682.25,390)" style="opacity: 1;"><rect width="389" height="118" x="-194.5" y="-59"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-45" fill="black" stroke="none" id="mermaid-diagram-1Text" style="text-anchor: middle;"> Web Client</text></g><g class="cluster" id="subGraph2" transform="translate(1807.125,426.5)" style="opacity: 1;"><rect width="902.75" height="813" x="-451.375" y="-406.5"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-392.5" fill="black" stroke="none" id="mermaid-diagram-1Text" style="text-anchor: middle;"> </text></g><g class="cluster" id="subGraph0" transform="translate(1991.25,426.5)" style="opacity: 1;"><rect width="494.5" height="763" x="-247.25" y="-381.5"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-367.5" fill="black" stroke="none" id="mermaid-diagram-1Text" style="text-anchor: middle;"> mORMot Client Delphi</text></g><g class="cluster" id="subGraph1" transform="translate(1549.875,426.5)" style="opacity: 1;"><rect width="348.25" height="477" x="-174.125" y="-238.5"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-224.5" fill="black" stroke="none" id="mermaid-diagram-1Text" style="text-anchor: middle;"> REST Client FPC/FMX/Smart/Java/C#..</text></g></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M1907,628L1907,665L1907,702L740,758.1149144254279" marker-end="url(#arrowhead335)" style="fill:none"></path><defs><marker id="arrowhead335" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1560.75,628L1560.75,665L1560.75,702L740,756.9806982685211" marker-end="url(#arrowhead336)" style="fill:none"></path><defs><marker id="arrowhead336" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M587.75,412L587.75,449L587.75,498L587.75,547L629.5,573.7018970189702" marker-end="url(#arrowhead337)" style="fill:none"></path><defs><marker id="arrowhead337" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M772.25,412L772.25,449L772.25,498L772.25,547L730.5,573.7018970189702" marker-end="url(#arrowhead338)" style="fill:none"></path><defs><marker id="arrowhead338" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M120.51408450704226,1377L88.25,1426L88.25,1463L88.25,1500" marker-end="url(#arrowhead339)" style="fill:none"></path><defs><marker id="arrowhead339" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M196.5,1362.2263136119157L739.25,1426L739.25,1463L739.25,1500" marker-end="url(#arrowhead340)" style="fill:none"></path><defs><marker id="arrowhead340" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1090.25,1223L1090.25,1272L1370.75,1343.3062787136294" marker-end="url(#arrowhead341)" style="fill:none"></path><defs><marker id="arrowhead341" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1237.75,1223L1237.75,1272L1512.75,1343.8897637795276" marker-end="url(#arrowhead342)" style="fill:none"></path><defs><marker id="arrowhead342" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M2000.5762711864406,114L2024.25,151L2024.25,188L2024.25,213" marker-end="url(#arrowhead343)" style="fill:none"></path><defs><marker id="arrowhead343" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1959.7457627118645,114L1914.75,151L1914.75,188L1914.75,235L1914.75,294L1914.75,331L1945.1525423728813,356" marker-end="url(#arrowhead344)" style="fill:none"></path><defs><marker id="arrowhead344" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1927.5,113.89308176100629L1827.5,151L1827.5,188L1827.5,235L1827.5,294L1827.5,331L1827.5,368" marker-end="url(#arrowhead345)" style="fill:none"></path><defs><marker id="arrowhead345" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1827.5,412L1827.5,449L1827.5,498L1827.5,547L1877.3559322033898,584" marker-end="url(#arrowhead346)" style="fill:none"></path><defs><marker id="arrowhead346" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M2041.5,114L2134,151L2134,188L2134,235L2134,294L2134,331L2134,390L2134,449L2134,498L2134,547L2134,606L2134,665L2134,702L2140.584745762712,739" marker-end="url(#arrowhead347)" style="fill:none"></path><defs><marker id="arrowhead347" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M2024.25,257L2024.25,294L2024.25,331L2008.2542372881355,356" marker-end="url(#arrowhead348)" style="fill:none"></path><defs><marker id="arrowhead348" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1986.5,424L1986.5,449L1986.5,498L1986.5,547L1936.6440677966102,584" marker-end="url(#arrowhead349)" style="fill:none"></path><defs><marker id="arrowhead349" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1965.5,619.0368271954674L2171.75,665L2171.75,702L2154.6610169491523,739" marker-end="url(#arrowhead350)" style="fill:none"></path><defs><marker id="arrowhead350" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1531.1059322033898,257L1481.25,294L1481.25,331L1481.25,356" marker-end="url(#arrowhead351)" style="fill:none"></path><defs><marker id="arrowhead351" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1590.3940677966102,257L1640.25,294L1640.25,331L1640.25,368" marker-end="url(#arrowhead352)" style="fill:none"></path><defs><marker id="arrowhead352" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1481.25,424L1481.25,449L1481.25,498L1481.25,547L1531.1059322033898,584" marker-end="url(#arrowhead353)" style="fill:none"></path><defs><marker id="arrowhead353" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M1640.25,412L1640.25,449L1640.25,498L1640.25,547L1590.3940677966102,584" marker-end="url(#arrowhead354)" style="fill:none"></path><defs><marker id="arrowhead354" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M680,640L680,665L680,702L680,739" marker-end="url(#arrowhead355)" style="fill:none"></path><defs><marker id="arrowhead355" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M620,779.252427184466L525.5,808L525.5,833L525.5,870L525.5,907" marker-end="url(#arrowhead356)" style="fill:none"></path><defs><marker id="arrowhead356" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M680.7021276595744,783L681.5,808L681.5,833L681.5,870L681.5,907" marker-end="url(#arrowhead357)" style="fill:none"></path><defs><marker id="arrowhead357" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M740,776.3678474114441L863.5,808L863.5,833L863.5,870L863.5,907" marker-end="url(#arrowhead358)" style="fill:none"></path><defs><marker id="arrowhead358" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M525.5,975L525.5,1012L679.75,1061.9355281207133" marker-end="url(#arrowhead359)" style="fill:none"></path><defs><marker id="arrowhead359" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M681.5,975L681.5,1012L697.9618644067797,1049" marker-end="url(#arrowhead360)" style="fill:none"></path><defs><marker id="arrowhead360" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M863.5,975L863.5,1012L735.75,1060.3932584269662" marker-end="url(#arrowhead361)" style="fill:none"></path><defs><marker id="arrowhead361" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M679.75,1074.8734363502576L368,1118L387.5422535211268,1155" marker-end="url(#arrowhead362)" style="fill:none"></path><defs><marker id="arrowhead362" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M735.75,1073.4830188679246L1237.75,1118L1237.75,1155" marker-end="url(#arrowhead363)" style="fill:none"></path><defs><marker id="arrowhead363" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M679.75,1073.9066813914965L255,1118L255,1143" marker-end="url(#arrowhead364)" style="fill:none"></path><defs><marker id="arrowhead364" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M735.75,1074.6785464709992L1065.5,1118L1078.3978873239437,1155" marker-end="url(#arrowhead365)" style="fill:none"></path><defs><marker id="arrowhead365" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M370,1197.7368421052631L68.25,1272L117.30722891566265,1333" marker-end="url(#arrowhead366)" style="fill:none"></path><defs><marker id="arrowhead366" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M405.5,1223L405.5,1272L530.4397590361446,1333" marker-end="url(#arrowhead367)" style="fill:none"></path><defs><marker id="arrowhead367" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M441,1194.9285714285713L902.5,1272L954.5993975903615,1321" marker-end="url(#arrowhead368)" style="fill:none"></path><defs><marker id="arrowhead368" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M740,767.0775862068965L1144,808L1144,833L1144,870L1144,941L1144,1012L1144,1071L1144,1118L1115.9894366197184,1155" marker-end="url(#arrowhead369)" style="fill:none"></path><defs><marker id="arrowhead369" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M620,766.0948509485095L126.5,808L126.5,833L126.5,870L126.5,941L126.5,1012L126.5,1071L126.5,1118L126.5,1189L126.5,1272L132.74698795180723,1333" marker-end="url(#arrowhead370)" style="fill:none"></path><defs><marker id="arrowhead370" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M620,771.722433460076L417,808L417,833L417,870L417,941L417,1012L417,1071L417,1118L411.00704225352115,1155" marker-end="url(#arrowhead371)" style="fill:none"></path><defs><marker id="arrowhead371" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M740,770.6907216494845L971,808L971,833L971,870L971,941L971,1012L971,1071L971,1118L971,1189L971,1272L982.6596385542168,1321" marker-end="url(#arrowhead372)" style="fill:none"></path><defs><marker id="arrowhead372" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M679.75,1073.3808231569426L155,1118L155,1189L155,1272L140.3012048192771,1333" marker-end="url(#arrowhead373)" style="fill:none"></path><defs><marker id="arrowhead373" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M707.75,1093L707.75,1118L707.75,1189L707.75,1272L610.5542168674699,1333" marker-end="url(#arrowhead374)" style="fill:none"></path><defs><marker id="arrowhead374" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M735.75,1075.2044728434505L1020.75,1118L1020.75,1189L1020.75,1272L1003.039156626506,1321" marker-end="url(#arrowhead375)" style="fill:none"></path><defs><marker id="arrowhead375" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(1907,702)" style="opacity: 1;"><g transform="translate(-38.5,-12)" class="label"><foreignObject width="77" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">REST JSON</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1560.75,702)" style="opacity: 1;"><g transform="translate(-38.5,-12)" class="label"><foreignObject width="77" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">REST JSON</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(772.25,498)" style="opacity: 1;"><g transform="translate(-21,-24)" class="label"><foreignObject width="42" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">HTTP<br>HTML</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(88.25,1463)" style="opacity: 1;"><g transform="translate(-14,-12)" class="label"><foreignObject width="28" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">SQL</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(2024.25,151)" style="opacity: 1;"><g transform="translate(-15,-12)" class="label"><foreignObject width="30" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">runs</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1914.75,235)" style="opacity: 1;"><g transform="translate(-15,-12)" class="label"><foreignObject width="30" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">asks</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(2134,390)" style="opacity: 1;"><g transform="translate(-15.5,-12)" class="label"><foreignObject width="31" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">uses</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(2024.25,294)" style="opacity: 1;"><g transform="translate(-15,-12)" class="label"><foreignObject width="30" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">asks</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1986.5,498)" style="opacity: 1;"><g transform="translate(-30,-12)" class="label"><foreignObject width="60" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">requests</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1481.25,294)" style="opacity: 1;"><g transform="translate(-15,-12)" class="label"><foreignObject width="30" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">asks</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1481.25,498)" style="opacity: 1;"><g transform="translate(-26.5,-12)" class="label"><foreignObject width="53" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">request</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(525.5,870)" style="opacity: 1;"><g transform="translate(-15.5,-12)" class="label"><foreignObject width="31" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">uses</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(681.5,870)" style="opacity: 1;"><g transform="translate(-15,-12)" class="label"><foreignObject width="30" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">runs</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(863.5,870)" style="opacity: 1;"><g transform="translate(-30,-12)" class="label"><foreignObject width="60" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">requests</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(525.5,1012)" style="opacity: 1;"><g transform="translate(-43,-12)" class="label"><foreignObject width="86" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">REST to SQL</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(405.5,1272)" style="opacity: 1;"><g transform="translate(-45.5,-12)" class="label"><foreignObject width="91" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">makes CRUD</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(902.5,1272)" style="opacity: 1;"><g transform="translate(-38.5,-12)" class="label"><foreignObject width="77" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">REST JSON</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(417,1012)" style="opacity: 1;"><g transform="translate(-45.5,-12)" class="label"><foreignObject width="91" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">makes CRUD</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(971,1071)" style="opacity: 1;"><g transform="translate(-45.5,-12)" class="label"><foreignObject width="91" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">makes CRUD</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="D1" transform="translate(680,606)" style="opacity: 1;"><rect rx="0" ry="0" x="-50.5" y="-34" width="101" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-40.5,-24)"><foreignObject width="81" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">VC/MVVM<br>Web Server</div></foreignObject></g></g></g><g class="node cyan" id="D2" transform="translate(680,761)" style="opacity: 1;"><rect rx="0" ry="0" x="-60" y="-22" width="120" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-50,-12)"><foreignObject width="100" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RESTful Server</div></foreignObject></g></g></g><g class="node cyan" id="D3" transform="translate(525.5,941)" style="opacity: 1;"><rect rx="0" ry="0" x="-40" y="-34" width="80" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-30,-24)"><foreignObject width="60" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Business<br>rules</div></foreignObject></g></g></g><g class="node cyan" id="D4" transform="translate(681.5,941)" style="opacity: 1;"><rect rx="0" ry="0" x="-66" y="-34" width="132" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-56,-24)"><foreignObject width="112" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Services<br>implementation</div></foreignObject></g></g></g><g class="node cyan" id="D5" transform="translate(863.5,941)" style="opacity: 1;"><rect rx="0" ry="0" x="-66" y="-34" width="132" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-56,-24)"><foreignObject width="112" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Authentication<br>(users, sessions)</div></foreignObject></g></g></g><g class="node cyan" id="D6" transform="translate(707.75,1071)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM</div></foreignObject></g></g></g><g class="node cyan" id="D7" transform="translate(405.5,1189)" style="opacity: 1;"><rect rx="0" ry="0" x="-35.5" y="-34" width="71" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-25.5,-24)"><foreignObject width="51" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">SQlite3<br>engine</div></foreignObject></g></g></g><g class="node cyan" id="D8" transform="translate(1237.75,1189)" style="opacity: 1;"><rect rx="0" ry="0" x="-63" y="-34" width="126" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-53,-24)"><foreignObject width="106" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Redirected<br>TSQLRestClient</div></foreignObject></g></g></g><g class="node cyan" id="D9" transform="translate(255,1189)" style="opacity: 1;"><rect rx="0" ry="0" x="-65" y="-46" width="130" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55,-36)"><foreignObject width="110" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Redirected<br>TSQLRestServer<br>ORM</div></foreignObject></g></g></g><g class="node cyan" id="D10" transform="translate(1090.25,1189)" style="opacity: 1;"><rect rx="0" ry="0" x="-34.5" y="-34" width="69" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-24.5,-24)"><foreignObject width="49" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">NoSQL<br>engine</div></foreignObject></g></g></g><g class="node cyan" id="D11" transform="translate(135,1355)" style="opacity: 1;"><rect rx="0" ry="0" x="-61.5" y="-22" width="123" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-51.5,-12)"><foreignObject width="103" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">external tables</div></foreignObject></g></g></g><g class="node cyan" id="D12" transform="translate(575.5,1355)" style="opacity: 1;"><rect rx="0" ry="0" x="-67.5" y="-22" width="135" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-57.5,-12)"><foreignObject width="115" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">SQLite3 data file</div></foreignObject></g></g></g><g class="node cyan" id="D13" transform="translate(990.75,1355)" style="opacity: 1;"><rect rx="0" ry="0" x="-79" y="-34" width="158" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-69,-24)"><foreignObject width="138" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">n-memory tables<br>JSON or binary files</div></foreignObject></g></g></g><g class="node cyan" id="A1" transform="translate(587.75,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-65" y="-22" width="130" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55,-12)"><foreignObject width="110" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Mobile Browser</div></foreignObject></g></g></g><g class="node cyan" id="A2" transform="translate(772.25,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-69.5" y="-22" width="139" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-59.5,-12)"><foreignObject width="119" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Desktop Browser</div></foreignObject></g></g></g><g class="node cyan" id="B1" transform="translate(1560.75,235)" style="opacity: 1;"><rect rx="0" ry="0" x="-59" y="-22" width="118" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-49,-12)"><foreignObject width="98" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">User Interface</div></foreignObject></g></g></g><g class="node cyan" id="B2" transform="translate(1481.25,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-70.5" y="-34" width="141" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-60.5,-24)"><foreignObject width="121" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM methods<br>over TSQLRecord</div></foreignObject></g></g></g><g class="node cyan" id="B3" transform="translate(1640.25,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-38.5" y="-22" width="77" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-28.5,-12)"><foreignObject width="57" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Services</div></foreignObject></g></g></g><g class="node cyan" id="B4" transform="translate(1560.75,606)" style="opacity: 1;"><rect rx="0" ry="0" x="-58.5" y="-22" width="117" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-48.5,-12)"><foreignObject width="97" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RESTful Client</div></foreignObject></g></g></g><g class="node cyan" id="C1" transform="translate(1986.5,92)" style="opacity: 1;"><rect rx="0" ry="0" x="-59" y="-22" width="118" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-49,-12)"><foreignObject width="98" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">User Interface</div></foreignObject></g></g></g><g class="node cyan" id="C2" transform="translate(2024.25,235)" style="opacity: 1;"><rect rx="0" ry="0" x="-45" y="-22" width="90" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-35,-12)"><foreignObject width="70" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Reporting</div></foreignObject></g></g></g><g class="node cyan" id="C3" transform="translate(1986.5,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-70.5" y="-34" width="141" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-60.5,-24)"><foreignObject width="121" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM methods<br>over TSQLRecord</div></foreignObject></g></g></g><g class="node cyan" id="C4" transform="translate(1827.5,390)" style="opacity: 1;"><rect rx="0" ry="0" x="-38.5" y="-22" width="77" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-28.5,-12)"><foreignObject width="57" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Services</div></foreignObject></g></g></g><g class="node cyan" id="C5" transform="translate(1907,606)" style="opacity: 1;"><rect rx="0" ry="0" x="-58.5" y="-22" width="117" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-48.5,-12)"><foreignObject width="97" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RESTful Client</div></foreignObject></g></g></g><g class="node cyan" id="C6" transform="translate(2144.5,761)" style="opacity: 1;"><rect rx="0" ry="0" x="-59" y="-22" width="118" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-49,-12)"><foreignObject width="98" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Business rules</div></foreignObject></g></g></g><g class="node cyan" id="E1" transform="translate(88.25,1534)" style="opacity: 1;"><rect rx="0" ry="0" x="-49.5" y="-34" width="99" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39.5,-24)"><foreignObject width="79" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">External<br>Database 1</div></foreignObject></g></g></g><g class="node cyan" id="E2" transform="translate(739.25,1534)" style="opacity: 1;"><rect rx="0" ry="0" x="-49.5" y="-34" width="99" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39.5,-24)"><foreignObject width="79" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">External<br>Database 2</div></foreignObject></g></g></g><g class="node cyan" id="E3" transform="translate(1416.75,1355)" style="opacity: 1;"><rect rx="0" ry="0" x="-46" y="-22" width="92" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-36,-12)"><foreignObject width="72" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">MongoDB</div></foreignObject></g></g></g><g class="node cyan" id="E4" transform="translate(1555.25,1355)" style="opacity: 1;"><rect rx="0" ry="0" x="-42.5" y="-46" width="85" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32.5,-36)"><foreignObject width="65" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">emote<br>mORMot<br>Server</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  您还可以使用以下公共特性：</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-2" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 864 202" style="max-width:864px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-2 .node&gt;rect { ; }
#mermaid-diagram-2 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-2 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-2 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-2 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"><g class="cluster" id="subGraph0" transform="translate(422,91)" style="opacity: 1;"><rect width="804" height="142" x="-402" y="-71"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-57" fill="black" stroke="none" id="mermaid-diagram-2Text" style="text-anchor: middle;"> Cross-Cutting features</text></g></g><g class="edgePaths"></g><g class="edgeLabels"></g><g class="nodes"><g class="node cyan" id="A1" transform="translate(106.5,91)" style="opacity: 1;"><rect rx="0" ry="0" x="-51.5" y="-46" width="103" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-41.5,-36)"><foreignObject width="83" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Logging<br>Unit Testing<br>Mocking</div></foreignObject></g></g></g><g class="node cyan" id="A2" transform="translate(247,91)" style="opacity: 1;"><rect rx="0" ry="0" x="-39" y="-46" width="78" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-29,-36)"><foreignObject width="58" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">JSON<br>Unicode<br>UTF-8</div></foreignObject></g></g></g><g class="node cyan" id="A3" transform="translate(398,91)" style="opacity: 1;"><rect rx="0" ry="0" x="-62" y="-34" width="124" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-52,-24)"><foreignObject width="104" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Remote access<br>Objects cache</div></foreignObject></g></g></g><g class="node cyan" id="A4" transform="translate(568.5,91)" style="opacity: 1;"><rect rx="0" ry="0" x="-58.5" y="-34" width="117" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-48.5,-24)"><foreignObject width="97" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Security<br>Cryptography</div></foreignObject></g></g></g><g class="node cyan" id="A5" transform="translate(733,91)" style="opacity: 1;"><rect rx="0" ry="0" x="-56" y="-34" width="112" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-46,-24)"><foreignObject width="92" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">File process<br>Compression</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  不要害怕，这幅图看起来庞大而令人困惑，尤其是当你有RAD（快速应用开发）开发经验，并且对现代设计模式接触不多时。</p>
<p>  后面会详细解释框架是如何实现这个架构的，示例代码可以帮助您认清惊人的mORMot领域。</p>
<p>  在前面的图示中，您已经可以确定mORMot的一些关键概念：</p>
<ul>
<li>跨平台、多客户端、多设备；</li>
<li>能够集成到现有的代码库或架构；</li>
<li>客户端-服务端基于REST的设计；</li>
<li>分层（多层）实现；</li>
<li>流程可以通过一组服务（SOA）来定义；</li>
<li>业务规则和数据模型由客户端和服务器共享；</li>
<li>数据由对象(ORM/ODM)映射；</li>
<li>数据库可以是嵌入式SQLite3、一个或多个标准RDBMS（具有自动生成的SQL）、MongoDB NoSQL引擎、快速内存对象列表或另一个mORMot服务器；</li>
<li>所有层都集成了安全性（身份验证和授权）；</li>
<li>可提供用户界面和报表类；</li>
<li>可以使用ORM/SOA方法编写MVC/MVVM AJAX或Web应用程序；</li>
<li>基于简单且经过验证的模式（REST、JSON、MVC、SOLID）；</li>
<li>集成了一致的测试调试API；</li>
<li>优化的伸缩和稳定性。</li>
</ul>
<h2 id="toc_2">2.2. 架构设计过程<a class="vnote-anchor" href="#toc_2" data-anchor-icon="#"></a></h2>
<p>  首先，你不能孤立地谈论架构。架构总是由应用程序的实际需求驱动的，而不是由架构师昨天晚上读到的内容驱动的，架构希望了解它在现实世界中的工作方式。没有这样的“一种架构适合所有人”，也没有“一种框架适合所有人”的解决方案。架构仅仅是考虑如何构建自己的软件。</p>
<p>  事实上，软件架构不是关于理论和图表，也不仅仅是关于最佳实践，而是关于为您的客户实现工作解决方案的一种方法。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-3" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 658.5 802" style="max-width:658.5px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-3 .node&gt;rect { ; }
#mermaid-diagram-3 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-3 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-3 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-3 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"><g class="cluster" id="subGraph4" transform="translate(245.75,668)" style="opacity: 1;"><rect width="394.5" height="188" x="-197.25" y="-94"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-80" fill="black" stroke="none" id="mermaid-diagram-3Text" style="text-anchor: middle;"> Customer</text></g><g class="cluster" id="subGraph3" transform="translate(319.25,248)" style="opacity: 1;"><rect width="598.5" height="456" x="-299.25" y="-228"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-214" fill="black" stroke="none" id="mermaid-diagram-3Text" style="text-anchor: middle;"> Team</text></g><g class="cluster" id="subGraph0" transform="translate(299,92)" style="opacity: 1;"><rect width="501" height="94" x="-250.5" y="-47"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-33" fill="black" stroke="none" id="mermaid-diagram-3Text" style="text-anchor: middle;"> BackLog</text></g><g class="cluster" id="subGraph1" transform="translate(359.5,248)" style="opacity: 1;"><rect width="478" height="118" x="-239" y="-59"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-45" fill="black" stroke="none" id="mermaid-diagram-3Text" style="text-anchor: middle;"> Design</text></g><g class="cluster" id="subGraph2" transform="translate(353.25,404)" style="opacity: 1;"><rect width="392.5" height="94" x="-196.25" y="-47"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-33" fill="black" stroke="none" id="mermaid-diagram-3Text" style="text-anchor: middle;"> Dev</text></g></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M249.45744680851064,114L208.5,139L208.5,164L208.5,189L208.5,214" marker-end="url(#arrowhead529)" style="fill:none"></path><defs><marker id="arrowhead529" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M321.54255319148933,114L362.5,139L362.5,164L362.5,189L362.5,214" marker-end="url(#arrowhead530)" style="fill:none"></path><defs><marker id="arrowhead530" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M331,101.37938596491227L513.5,139L513.5,164L513.5,189L513.5,214" marker-end="url(#arrowhead531)" style="fill:none"></path><defs><marker id="arrowhead531" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M208.5,282L208.5,307L208.5,332L208.5,357L339,395.69716088328073" marker-end="url(#arrowhead532)" style="fill:none"></path><defs><marker id="arrowhead532" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M362.5,282L362.5,307L362.5,332L362.5,357L364.8936170212766,382" marker-end="url(#arrowhead533)" style="fill:none"></path><defs><marker id="arrowhead533" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M513.5,282L513.5,307L513.5,332L513.5,357L395,395.01706484641636" marker-end="url(#arrowhead534)" style="fill:none"></path><defs><marker id="arrowhead534" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M367,426L367,451L367,476L367,525L367,574L367,599" marker-end="url(#arrowhead535)" style="fill:none"></path><defs><marker id="arrowhead535" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M240,102.85532994923858L88.5,139L88.5,164L88.5,189L88.5,248L88.5,307L88.5,332L88.5,357L88.5,404L88.5,451L88.5,476L88.5,525L88.5,574L88.5,621L88.5,668L205.25,705.2648556876061" marker-end="url(#arrowhead536)" style="fill:none"></path><defs><marker id="arrowhead536" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M367,643L367,668L266.25,704.0780952380952" marker-end="url(#arrowhead537)" style="fill:none"></path><defs><marker id="arrowhead537" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(367,525)" style="opacity: 1;"><g transform="translate(-34.5,-24)" class="label"><foreignObject width="69" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Definition<br>of Done</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(88.5,404)" style="opacity: 1;"><g transform="translate(-48.5,-12)" class="label"><foreignObject width="97" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Requirements</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="D1" transform="translate(367,621)" style="opacity: 1;"><rect rx="0" ry="0" x="-41" y="-22" width="82" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-31,-12)"><foreignObject width="62" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Software</div></foreignObject></g></g></g><g class="node cyan" id="D2" transform="translate(235.75,715)" style="opacity: 1;"><rect rx="0" ry="0" x="-30.5" y="-22" width="61" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-20.5,-12)"><foreignObject width="41" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client</div></foreignObject></g></g></g><g class="node cyan" id="C" transform="translate(367,404)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Tasks</div></foreignObject></g></g></g><g class="node cyan" id="B1" transform="translate(208.5,248)" style="opacity: 1;"><rect rx="0" ry="0" x="-53" y="-34" width="106" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-43,-24)"><foreignObject width="86" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Architecture<br>Proposal</div></foreignObject></g></g></g><g class="node cyan" id="B2" transform="translate(362.5,248)" style="opacity: 1;"><rect rx="0" ry="0" x="-51" y="-34" width="102" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-41,-24)"><foreignObject width="82" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Risk<br>Assessment</div></foreignObject></g></g></g><g class="node cyan" id="B3" transform="translate(513.5,248)" style="opacity: 1;"><rect rx="0" ry="0" x="-50" y="-34" width="100" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-40,-24)"><foreignObject width="80" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Technology<br>&amp; Models</div></foreignObject></g></g></g><g class="node cyan" id="A" transform="translate(285.5,92)" style="opacity: 1;"><rect rx="0" ry="0" x="-45.5" y="-22" width="91" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-35.5,-12)"><foreignObject width="71" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Use Cases</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  这个图表展示了架构是典型的SCRUM敏捷迭代过程的一部分。即使您公司的某些人可能负责全球软件体系结构，或者即使您的项目管理遵循经典的v循环而不遵循敏捷宣言，体系结构也不应该被看作是一组规则，被每个开发人员应用。体系结构是编码的一部分，但不是全部编码。</p>
<p>  <strong><em>译者注：Scrum是迭代式增量软件开发过程，通常用于敏捷软件开发。Scrum包括了一系列实践和预定义角色的过程骨架。Scrum中的主要角色包括同项目经理类似的Scrum主管角色负责维护过程和任务，产品负责人代表利益所有者，开发团队包括了所有开发人员。虽然Scrum是为管理软件开发项目而开发的，它同样可以用于运行软件维护团队，或者作为计划管理方法。</em></strong></p>
<p>  以下是一些实现渐进式设计的方法：</p>
<ul>
<li>让每个开发人员根据自己的知识（和心情?）来决定如何实现用例，而不需要审查、实现文档或对等协作；</li>
<li>让每个团队根据自己的知识（以及不为人知的内部领导?）来决定如何在没有系统范围协作的情况下实现用例；</li>
<li>让架构应该在相对较高的层次上被决定，而不会影响开发人员的实际编码风格（无感知）；</li>
<li>让架构变得无处不在，以至于每一行代码都必须遵循一个典型的实现模式，生成符合架构要求的工程代码；</li>
<li>让架构满足当前目标，当然最好有一些中期目标；</li>
<li>让技术、框架或刚刚发表的想法不受歧视地使用（不要相信开发营销的危言耸听）。</li>
</ul>
<p>  因此，一些建议：</p>
<ul>
<li>协作是一种需要，没有人是独自战斗的，单个团队不可能完成所有工作，也没有管理者总是正确的；</li>
<li>分享是一种需要，个人之间、团队之间、管理者之间;</li>
<li>以客户和内容为中心；</li>
<li>今天的实现是明天的准备；</li>
<li>放松，也就是说，试着让你和你的团队成员更轻松地完成明天的工作;</li>
<li>他们不知道这是不可能的，所以他们做了。</li>
</ul>
<p>  mORMot框架的目的就是为您的团队提供工作所需的集成的类集合，这样您就可以专注于您的产品，享受与其他开源用户的协作，以便使用不断发展的适用的软件架构。</p>
<h2 id="toc_3">2.3. 模型-视图-控制器<a class="vnote-anchor" href="#toc_3" data-anchor-icon="#"></a></h2>
<p>  模型-视图-控制器（MVC）是一种软件架构，是目前软件工程中使用的一种架构模式。模式将“域逻辑”（用户的应用程序逻辑）与用户界面（输入和表现）隔离开来，允许逐个（关注点分离）进行独立开发、测试和维护。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-4" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 369 222" style="max-width:369px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-4 .node&gt;rect { ; }
#mermaid-diagram-4 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-4 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-4 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-4 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M103.89855072463769,79L187,32L264,47.470319634703195" marker-end="url(#arrowhead553)" style="fill:none"></path><defs><marker id="arrowhead553" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M264,61.42009132420091L187,79L110,92.88524590163934" marker-end="url(#arrowhead554)" style="fill:none"></path><defs><marker id="arrowhead554" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M110,109.11475409836066L187,123L269.5,141.83561643835617" marker-end="url(#arrowhead555)" style="fill:none"></path><defs><marker id="arrowhead555" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M269.5,153.42465753424656L187,170L103.89855072463769,123" marker-end="url(#arrowhead556)" style="fill:none"></path><defs><marker id="arrowhead556" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(187,32)" style="opacity: 1;"><g transform="translate(-13,-12)" class="label"><foreignObject width="26" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Use</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(187,79)" style="opacity: 1;"><g transform="translate(-52,-12)" class="label"><foreignObject width="104" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Notify updates</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(187,123)" style="opacity: 1;"><g transform="translate(-26,-12)" class="label"><foreignObject width="52" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Refresh</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(187,170)" style="opacity: 1;"><g transform="translate(-36.5,-12)" class="label"><foreignObject width="73" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Command</span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="C" transform="translate(65,101)" style="opacity: 1;"><rect rx="0" ry="0" x="-45" y="-22" width="90" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-35,-12)"><foreignObject width="70" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Controller</div></foreignObject></g></g></g><g class="node cyan" id="M" transform="translate(296.5,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-32.5" y="-22" width="65" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-22.5,-12)"><foreignObject width="45" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Model</div></foreignObject></g></g></g><g class="node cyan" id="V" transform="translate(296.5,148)" style="opacity: 1;"><rect rx="0" ry="0" x="-27" y="-22" width="54" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-17,-12)"><foreignObject width="34" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">View</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  模型管理应用领域的行为和数据，响应有关其状态信息的请求（通常来自视图），响应更改状态的指令（通常来自控制器）。在事件驱动系统中，当信息发生变化时，模型会通知观察器（通常是视图），以便他们能够做出反应，而我们的ORM是无状态的，所以它不需要处理这些事件，参见<a href="">无状态ORM</a>部分。</p>
<p>  视图将模型呈现为适合交互的表单，通常是用户界面元素。为了不同的目的，一个模型通常存在多个视图。典型的，视图通常与外观显示一一对应，并知道如何渲染它。</p>
<p>  控制器接收用户输入并通过调用模型对象发起响应。控制器接受用户的输入，并指示模型和视图根据输入执行操作。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-5" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 710 178.5" style="max-width:710px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-5 .node&gt;rect { ; }
#mermaid-diagram-5 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-5 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-5 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-5 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M85,79.56573705179282L178,54L305.5,54" marker-end="url(#arrowhead578)" style="fill:none"></path><defs><marker id="arrowhead578" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M359.5,50.15533980582524L487,32L580,61.65217391304348" marker-end="url(#arrowhead579)" style="fill:none"></path><defs><marker id="arrowhead579" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M580,76L487,76L359.5,57.84466019417476" marker-end="url(#arrowhead580)" style="fill:none"></path><defs><marker id="arrowhead580" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M580,92.46739130434783L487,126.5L332.5,126.5L178,126.5L85,98.34063745019921" marker-end="url(#arrowhead581)" style="fill:none"></path><defs><marker id="arrowhead581" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(178,54)" style="opacity: 1;"><g transform="translate(-68,-12)" class="label"><foreignObject width="136" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">indirect association</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(487,32)" style="opacity: 1;"><g transform="translate(-68,-12)" class="label"><foreignObject width="136" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">indirect association</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(487,76)" style="opacity: 1;"><g transform="translate(-61.5,-12)" class="label"><foreignObject width="123" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">direct association</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(332.5,126.5)" style="opacity: 1;"><g transform="translate(-61.5,-12)" class="label"><foreignObject width="123" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">direct association</span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="M" transform="translate(52.5,88.5)" style="opacity: 1;"><rect rx="0" ry="0" x="-32.5" y="-22" width="65" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-22.5,-12)"><foreignObject width="45" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Model</div></foreignObject></g></g></g><g class="node cyan" id="V" transform="translate(332.5,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-27" y="-22" width="54" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-17,-12)"><foreignObject width="34" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">View</div></foreignObject></g></g></g><g class="node cyan" id="C" transform="translate(625,76)" style="opacity: 1;"><rect rx="0" ry="0" x="-45" y="-22" width="90" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-35,-12)"><foreignObject width="70" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Controller</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  在框架中，模型不一定只是一个数据库；MVC中的模型是应用程序所需要的各种数据和业务/领域逻辑的总和。在我们的ORM中，模型是通过TSQLModel类实现的，TSQLModel类集中了应用程序用到的所有TSQLRecord派生类，包括与数据库相关的类和与业务逻辑相关的类。<br>
  视图可以通过以下方式实现：</p>
<ul>
<li>对于桌面客户端，框架的一整套用户界面单元，大部分是由代码自动生成的，它们将根据模型呈现数据；</li>
<li>对于Web客户端，集成的高速Mustache渲染引擎（参见<a href="">Mustache模版引擎</a>）能够使用无逻辑模板呈现HTML页面，并嵌入Delphi编写的控制器方法（参见<a href="">MVC/MVVM Web应用</a>）；</li>
<li>对于AJAX客户端，可以通过RESTful JSON服务轻松访问服务端。</li>
</ul>
<p>  控制器已经在我们的框架中基本实现了，通过RESTful提交命令，完成与相关视图（如刷新用户界面）和模型（用于数据处理）交互。一些与业务逻辑相关的自定义操作可以通过自定义TSQLRecord类或自定义RESTful服务来实现，参见<a href="">服务端服务</a>。</p>
<h2 id="toc_4">2.4. 多层架构<a class="vnote-anchor" href="#toc_4" data-anchor-icon="#"></a></h2>
<p>  在软件工程中，多层架构（通常称为n层架构）是一个客户端服务端架构，应用的表现、处理和数据管理是逻辑上独立的进程。例如，使用中间件在用户和数据库之间请求数据服务的应用程序应该采用多层架构。多层架构最广泛的应用是三层体系结构。</p>
<p>  实际上，用Delphi编写的典型VCL/FMX RAD应用程序具有两层架构：</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-6" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 191 198" style="max-width:191px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-6 .node&gt;rect { ; }
#mermaid-diagram-6 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-6 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-6 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-6 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M85.5,64L85.5,89L85.5,114" marker-end="url(#arrowhead588)" style="fill:none"></path><defs><marker id="arrowhead588" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="A" transform="translate(85.5,42)" style="opacity: 1;"><rect rx="0" ry="0" x="-65.5" y="-22" width="131" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55.5,-12)"><foreignObject width="111" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Application Tier</div></foreignObject></g></g></g><g class="node cyan" id="D" transform="translate(85.5,136)" style="opacity: 1;"><rect rx="0" ry="0" x="-42" y="-22" width="84" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32,-12)"><foreignObject width="64" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Data Tier</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  在这种方式中，应用程序层在表单和模块中混合了UI和逻辑。</p>
<p>  我们的RESTful框架在ORM和SOA方面都使得三层架构的开发变得很容易。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-7" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 199 292" style="max-width:199px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-7 .node&gt;rect { ; }
#mermaid-diagram-7 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-7 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-7 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-7 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M89.5,64L89.5,89L89.5,114" marker-end="url(#arrowhead600)" style="fill:none"></path><defs><marker id="arrowhead600" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M89.5,158L89.5,183L89.5,208" marker-end="url(#arrowhead601)" style="fill:none"></path><defs><marker id="arrowhead601" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="P" transform="translate(89.5,42)" style="opacity: 1;"><rect rx="0" ry="0" x="-69.5" y="-22" width="139" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-59.5,-12)"><foreignObject width="119" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Presentation Tier</div></foreignObject></g></g></g><g class="node cyan" id="L" transform="translate(89.5,136)" style="opacity: 1;"><rect rx="0" ry="0" x="-44" y="-22" width="88" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-34,-12)"><foreignObject width="68" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Logic Tier</div></foreignObject></g></g></g><g class="node cyan" id="D" transform="translate(89.5,230)" style="opacity: 1;"><rect rx="0" ry="0" x="-42" y="-22" width="84" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32,-12)"><foreignObject width="64" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Data Tier</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  Synopse mORMot框架遵循以下开发模式：</p>
<ul>
<li>数据层采用SQLite3或高速内存数据库；很多SQL查询是动态创建的，数据库表是用Delphi类定义的；可以使用各种外部数据库，目前支持SQLite3、Oracle、Jet/MSAccess、MS SQL、Firebird、DB2、PostgreSQL、MySQL、Informix和NexusDB SQL等，也包括MongoDB这样的NoSQL引擎，参加<a href="">访问外部SQL数据库</a>部分；</li>
<li>逻辑层是纯粹用ORM和SOA实现：Delphi类通过数据层映射到数据库中，业务逻辑使用Delphi的interface服务化，如果你的项目达到某种程度的复杂性，还可采用领域驱动设计，参见<a href="">领域驱动设计</a>；</li>
<li>表示层是Delphi客户端，或AJAX应用程序，框架支持基于通过HTTP / 1.1的RESTful JSON通信（Delphi客户端界面通过RTTI和结构代码生成，而不是作为一个RAD，AJAX应用程序需要使用自己的工具和JavaScript框架编写，目前还没有包括“官方”的AJAX框架）。</li>
</ul>
<p>  事实上，mORMot可以扩展到领域驱动设计的四层架构，如下所示：</p>
<ul>
<li>表示层，例如Delphi或AJAX客户端；</li>
<li>为客户端应用程序提供JSON内容的应用层；</li>
<li>业务逻辑层，集中所有领域处理，在所有应用程序之间共享;</li>
<li>持久化/数据层，可以是进程内（如SQLite3或内存中），也可以是外部（如Oracle、MS SQL、DB2、PostgreSQL、MySQL、Informix…）。</li>
</ul>
<div class="mermaid-diagram"><svg id="mermaid-diagram-8" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 212 386" style="max-width:212px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-8 .node&gt;rect { ; }
#mermaid-diagram-8 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-8 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-8 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-8 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M96,64L96,89L96,114" marker-end="url(#arrowhead618)" style="fill:none"></path><defs><marker id="arrowhead618" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M96,158L96,183L96,208" marker-end="url(#arrowhead619)" style="fill:none"></path><defs><marker id="arrowhead619" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M96,252L96,277L96,302" marker-end="url(#arrowhead620)" style="fill:none"></path><defs><marker id="arrowhead620" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="P" transform="translate(96,42)" style="opacity: 1;"><rect rx="0" ry="0" x="-69.5" y="-22" width="139" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-59.5,-12)"><foreignObject width="119" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Presentation Tier</div></foreignObject></g></g></g><g class="node cyan" id="A" transform="translate(96,136)" style="opacity: 1;"><rect rx="0" ry="0" x="-65.5" y="-22" width="131" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55.5,-12)"><foreignObject width="111" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Application Tier</div></foreignObject></g></g></g><g class="node cyan" id="B" transform="translate(96,230)" style="opacity: 1;"><rect rx="0" ry="0" x="-76" y="-22" width="152" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-66,-12)"><foreignObject width="132" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Business Logic Tier</div></foreignObject></g></g></g><g class="node cyan" id="D" transform="translate(96,324)" style="opacity: 1;"><rect rx="0" ry="0" x="-42" y="-22" width="84" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32,-12)"><foreignObject width="64" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Data Tier</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  您必须在物理和逻辑的n层体系结构之间做出选择。大多数情况下，n层是一个物理（硬件）视图，例如数据库服务器和应用服务器之间的分离，将数据库放在单独的机器上以方便维护。在mORMot中，或通常的SOA中(参见<a href="">接口</a>)，我们的逻辑层次是接口的分层（参见<a href="">接口</a>），底层硬件实现通常与逻辑布局不一致。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-9" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 498 536" style="max-width:498px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-9 .node&gt;rect { ; }
#mermaid-diagram-9 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-9 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-9 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-9 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"><g class="cluster" id="subGraph3" transform="translate(239,449)" style="opacity: 1;"><rect width="154" height="94" x="-77" y="-47"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-33" fill="black" stroke="none" id="mermaid-diagram-9Text" style="text-anchor: middle;"> DB Server</text></g><g class="cluster" id="subGraph2" transform="translate(234,258)" style="opacity: 1;"><rect width="370" height="188" x="-185" y="-94"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-80" fill="black" stroke="none" id="mermaid-diagram-9Text" style="text-anchor: middle;"> Application Server</text></g><g class="cluster" id="subGraph1" transform="translate(353.5,67)" style="opacity: 1;"><rect width="209" height="94" x="-104.5" y="-47"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-33" fill="black" stroke="none" id="mermaid-diagram-9Text" style="text-anchor: middle;"> Client2 AJAX</text></g><g class="cluster" id="subGraph0" transform="translate(124.5,67)" style="opacity: 1;"><rect width="209" height="94" x="-104.5" y="-47"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-33" fill="black" stroke="none" id="mermaid-diagram-9Text" style="text-anchor: middle;"> Client1 Delphi</text></g></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M124.5,89L124.5,114L124.5,139L124.5,164L185.40425531914894,189" marker-end="url(#arrowhead692)" style="fill:none"></path><defs><marker id="arrowhead692" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M353.5,89L353.5,114L353.5,139L353.5,164L292.59574468085106,189" marker-end="url(#arrowhead693)" style="fill:none"></path><defs><marker id="arrowhead693" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M239,327L239,352L239,377L239,402L239,427" marker-end="url(#arrowhead694)" style="fill:none"></path><defs><marker id="arrowhead694" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M239,233L239,258L239,283" marker-end="url(#arrowhead695)" style="fill:none"></path><defs><marker id="arrowhead695" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="D" transform="translate(239,449)" style="opacity: 1;"><rect rx="0" ry="0" x="-42" y="-22" width="84" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32,-12)"><foreignObject width="64" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Data Tier</div></foreignObject></g></g></g><g class="node cyan" id="A" transform="translate(239,211)" style="opacity: 1;"><rect rx="0" ry="0" x="-65.5" y="-22" width="131" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55.5,-12)"><foreignObject width="111" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Application Tier</div></foreignObject></g></g></g><g class="node cyan" id="B" transform="translate(239,305)" style="opacity: 1;"><rect rx="0" ry="0" x="-76" y="-22" width="152" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-66,-12)"><foreignObject width="132" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Business Logic Tier</div></foreignObject></g></g></g><g class="node cyan" id="P2" transform="translate(353.5,67)" style="opacity: 1;"><rect rx="0" ry="0" x="-69.5" y="-22" width="139" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-59.5,-12)"><foreignObject width="119" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Presentation Tier</div></foreignObject></g></g></g><g class="node cyan" id="P1" transform="translate(124.5,67)" style="opacity: 1;"><rect rx="0" ry="0" x="-69.5" y="-22" width="139" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-59.5,-12)"><foreignObject width="119" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Presentation Tier</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  在本文中，我们将重点讨论思路/编码的逻辑方式，而让物理部署根据最终用户的期望去实施。</p>
<h2 id="toc_5">2.5. 面向服务的架构（SOA）<a class="vnote-anchor" href="#toc_5" data-anchor-icon="#"></a></h2>
<p>  面向服务的体系结构(SOA)是一套灵活的设计原则，用于系统开发和信息处理集成阶段。基于SOA的系统将把功能打包为一组可互操作的服务，这些服务可以在多个不同业务领域的系统中独立使用。</p>
<p>  软件服务是可重复活动的逻辑表示。简而言之，消费者要求生产者采取行动以获得结果。在大多数情况下，此调用不受以前任何调用的影响（因此称为无状态调用）。</p>
<p>  SOA的实现建立在一组软件服务基础上。服务由不相关的、松散耦合的功能单元组成，这些功能单元之间没有相互调用。每个服务都执行一个操作，比如填写一个在线账户申请，或者查看一个在线银行对账单，或者发布一个在线预订或机票订单。它们使用定义好的协议向服务描述如何使用元数据传递和解析消息，而不是在源代码中嵌入服务间的调用。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-10" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 566 402" style="max-width:566px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-10 .node&gt;rect { ; }
#mermaid-diagram-10 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-10 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-10 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-10 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"><g class="cluster" id="subGraph2" transform="translate(82.5,191)" style="opacity: 1;"><rect width="125" height="342" x="-62.5" y="-171"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-157" fill="black" stroke="none" id="mermaid-diagram-10Text" style="text-anchor: middle;"> Consumers</text></g><g class="cluster" id="subGraph1" transform="translate(269,191)" style="opacity: 1;"><rect width="148" height="342" x="-74" y="-171"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-157" fill="black" stroke="none" id="mermaid-diagram-10Text" style="text-anchor: middle;"> Service Bus</text></g><g class="cluster" id="subGraph0" transform="translate(459.5,181.75)" style="opacity: 1;"><rect width="133" height="323.5" x="-66.5" y="-161.75"></rect><g class="label"><g transform="translate(0,0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"></div></foreignObject></g></g><text x="0" y="-147.75" fill="black" stroke="none" id="mermaid-diagram-10Text" style="text-anchor: middle;"> Publishers</text></g></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M120,77L145,77L170,77L195,77L220,77" marker-end="url(#arrowhead772)" style="fill:none"></path><defs><marker id="arrowhead772" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M106.62280701754386,99L145,134L170,134L195,134L240.43859649122805,169" marker-end="url(#arrowhead773)" style="fill:none"></path><defs><marker id="arrowhead773" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M119.5,205.08L145,201L170,201L195,201L220,197.6216216216216" marker-end="url(#arrowhead774)" style="fill:none"></path><defs><marker id="arrowhead774" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M119.5,232.904L145,248L170,248L195,248L240.43859649122805,283" marker-end="url(#arrowhead775)" style="fill:none"></path><defs><marker id="arrowhead775" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M120,305L145,305L170,305L195,305L220,305" marker-end="url(#arrowhead776)" style="fill:none"></path><defs><marker id="arrowhead776" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M318,77L343,77L368,77L393,77L418,77" marker-end="url(#arrowhead777)" style="fill:none"></path><defs><marker id="arrowhead777" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M318,177.75675675675674L343,171L368,171L393,171L418,171" marker-end="url(#arrowhead778)" style="fill:none"></path><defs><marker id="arrowhead778" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M318,305L343,305L368,305L393,305L422.925,287" marker-end="url(#arrowhead779)" style="fill:none"></path><defs><marker id="arrowhead779" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M318,208.8783783783784L343,218L368,218L393,218L428.3723404255319,243" marker-end="url(#arrowhead780)" style="fill:none"></path><defs><marker id="arrowhead780" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M418,248.15037593984962L393,238L368,238L343,238L303.63829787234044,213" marker-end="url(#arrowhead781)" style="fill:none"></path><defs><marker id="arrowhead781" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="C1" transform="translate(82.5,77)" style="opacity: 1;"><rect rx="0" ry="0" x="-37.5" y="-22" width="75" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-27.5,-12)"><foreignObject width="55" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client A</div></foreignObject></g></g></g><g class="node cyan" id="C2" transform="translate(82.5,211)" style="opacity: 1;"><rect rx="0" ry="0" x="-37" y="-22" width="74" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-27,-12)"><foreignObject width="54" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client B</div></foreignObject></g></g></g><g class="node cyan" id="C3" transform="translate(82.5,305)" style="opacity: 1;"><rect rx="0" ry="0" x="-37.5" y="-22" width="75" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-27.5,-12)"><foreignObject width="55" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client C</div></foreignObject></g></g></g><g class="node cyan" id="P1" transform="translate(269,77)" style="opacity: 1;"><rect rx="0" ry="0" x="-49" y="-22" width="98" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39,-12)"><foreignObject width="78" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Publisher 1</div></foreignObject></g></g></g><g class="node cyan" id="P2" transform="translate(269,191)" style="opacity: 1;"><rect rx="0" ry="0" x="-49" y="-22" width="98" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39,-12)"><foreignObject width="78" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Publisher 2</div></foreignObject></g></g></g><g class="node cyan" id="P3" transform="translate(269,305)" style="opacity: 1;"><rect rx="0" ry="0" x="-49" y="-22" width="98" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39,-12)"><foreignObject width="78" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Publisher 3</div></foreignObject></g></g></g><g class="node cyan" id="S1" transform="translate(459.5,77)" style="opacity: 1;"><rect rx="0" ry="0" x="-41.5" y="-22" width="83" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-31.5,-12)"><foreignObject width="63" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Service 1</div></foreignObject></g></g></g><g class="node cyan" id="S2" transform="translate(459.5,171)" style="opacity: 1;"><rect rx="0" ry="0" x="-41.5" y="-22" width="83" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-31.5,-12)"><foreignObject width="63" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Service 2</div></foreignObject></g></g></g><g class="node cyan" id="S3" transform="translate(459.5,265)" style="opacity: 1;"><rect rx="0" ry="0" x="-41.5" y="-22" width="83" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-31.5,-12)"><foreignObject width="63" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Service 3</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  由于大多数服务定义为无状态的，因此通常会定义一些服务的组合以提供多层的逻辑服务。更高级的服务调用多个服务来作为自包含的无状态服务工作；因此，较底层的服务仍然是无状态的，但是高级服务的使用者能够安全地处理某些事务流程。</p>
<pre><code class="lang-mermaid hljs">
</code></pre>
<p>  有关SOA的详细信息，请参阅http://en.wikipedia.org/wiki/serviceoriented_architecture<br>
  SOA核心是解耦合。<br>
  也就是说，它可以通过多种方式独立实现，例如：</p>
<table>
<thead>
<tr>
<th>依赖</th>
<th>理想的解耦</th>
<th>解耦技术</th>
</tr>
</thead>
<tbody>
<tr>
<td>平台</td>
<td>硬件、框架或操作系统不应限制服务使用者的选择</td>
<td>标准协议，主要是Web服务（例如SOAP或RESTful/JSON）</td>
</tr>
<tr>
<td>位置</td>
<td>使用者应该不受服务主机更改的影响</td>
<td>通过路由和代理维护服务访问</td>
</tr>
<tr>
<td>可用性</td>
<td>维护任务应该是透明的</td>
<td>在服务器端集中提供远程访问支持</td>
</tr>
<tr>
<td>版本</td>
<td>引入新服务，无需客户端升级</td>
<td>在服务器端实现业务封装</td>
</tr>
</tbody>
</table>
<p>  SOA和ORM(参见<a href="">对象关系映射</a>)并不排斥它们自己。事实上，即使一些软件架构师倾向于只使用这两种特性中的一种，它们也可以共存，并在各中客户端-服务端应用程序中相互支撑：</p>
<ul>
<li>ORM访问可以用来访问数据对象，将服务端或客户端数据在本地呈现（Delphi，JavaScript…），所以可以使用ORM提供高效的数据和业务逻辑访问的思路就是CQRS模式；</li>
<li>SOA可提供更高级的业务逻辑的处理方法：使用自定义参数和数据类型，可以向客户机提供一些高级服务，隐藏大部分业务逻辑，并减少所需的带宽。</li>
</ul>
<p>  特别是，SOA有利于将业务逻辑放在服务端，有助于增加调整多层体系结构。通过减少客户端和服务端之间的交互，能减少网络带宽、服务器资源（在服务端运行服务、添加所有远程连接和序列化所需的数据库访问的总成本低于在客户机运行服务）。我们的基于接口的SOA模型允许在客户端和服务器端运行相同的代码，在服务器端有更好的性能，但是双方都具有完全的互操作性。</p>
<h2 id="toc_6">2.6. 对象关系映射（ORM）<a class="vnote-anchor" href="#toc_6" data-anchor-icon="#"></a></h2>
<p>  在实践中，ORM提供了一组方法来简化高级对象在RDBMS中的持久性。</p>
<p>  我们的Delphi类实例不是直接使用关系数据库，虽然这是几十年来最方便的数据持久化方法。因此，需要某种“粘合剂”来将类属性保存到一个或多个表中。您可以使用数据库的本地语言（即SQL）与数据库交互。而SQL本身是一种完整的编程语言，其风格取决于具体的后端引擎（请考虑如何定义能够存储文本的列类型）。因此，编写和维护SQL语句可能会成为一项费时、困难且容易出错的任务。</p>
<p>  有时候，没有什么比优化SQL语句更好的了，它能够聚合和连接来自多个表的信息。但多数情况下，您只需要对指定的对象执行一些基本操作，即CRUD（用于创建检索更新删除操作）：在这方面我们的ORM可以带给您一个巨大的惊喜，因为它能够为您生成SQL语句。</p>
<p>  ORM的工作原理如下：</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-12" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 165.25 506" style="max-width:165.25px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-12 .node&gt;rect { ; }
#mermaid-diagram-12 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-12 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-12 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-12 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M74.47289156626506,88L57.5,137L77.34154929577466,186" marker-end="url(#arrowhead808)" style="fill:none"></path><defs><marker id="arrowhead808" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M76.64830508474576,230L60.5,267L76.64830508474576,304" marker-end="url(#arrowhead809)" style="fill:none"></path><defs><marker id="arrowhead809" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M76.64830508474576,348L60.5,385L76.64830508474576,422" marker-end="url(#arrowhead810)" style="fill:none"></path><defs><marker id="arrowhead810" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M95.85169491525424,422L112,385L95.85169491525424,348" marker-end="url(#arrowhead811)" style="fill:none"></path><defs><marker id="arrowhead811" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M95.85169491525424,304L112,267L95.85169491525424,230" marker-end="url(#arrowhead812)" style="fill:none"></path><defs><marker id="arrowhead812" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M95.15845070422534,186L115,137L98.02710843373494,88" marker-end="url(#arrowhead813)" style="fill:none"></path><defs><marker id="arrowhead813" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(57.5,137)" style="opacity: 1;"><g transform="translate(-37.5,-24)" class="label"><foreignObject width="75" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">CRUD<br>operations</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(60.5,267)" style="opacity: 1;"><g transform="translate(-31.5,-12)" class="label"><foreignObject width="63" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">mapping</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(60.5,385)" style="opacity: 1;"><g transform="translate(-31.5,-12)" class="label"><foreignObject width="63" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">DB client</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="A" transform="translate(86.25,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-39" y="-34" width="78" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-29,-24)"><foreignObject width="58" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Object<br>instance</div></foreignObject></g></g></g><g class="node cyan" id="B" transform="translate(86.25,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM</div></foreignObject></g></g></g><g class="node cyan" id="C" transform="translate(86.25,326)" style="opacity: 1;"><rect rx="0" ry="0" x="-24" y="-22" width="48" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-14,-12)"><foreignObject width="28" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">SQL</div></foreignObject></g></g></g><g class="node cyan" id="D" transform="translate(86.25,444)" style="opacity: 1;"><rect rx="0" ry="0" x="-36.5" y="-22" width="73" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-26.5,-12)"><foreignObject width="53" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RDBMS</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  ORM核心获取信息并执行映射：</p>
<ul>
<li>通过<code>class</code>类型（通过RTTI）定义对象；</li>
<li>从每个数据库引擎获取数据库模型。</li>
</ul>
<div class="mermaid-diagram"><svg id="mermaid-diagram-13" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 322.5 292" style="max-width:322.5px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-13 .node&gt;rect { ; }
#mermaid-diagram-13 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-13 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-13 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-13 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M129.75,59.60535117056856L83,89L83,114" marker-end="url(#arrowhead827)" style="fill:none"></path><defs><marker id="arrowhead827" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M185.75,59.60535117056856L232.5,89L232.5,114" marker-end="url(#arrowhead828)" style="fill:none"></path><defs><marker id="arrowhead828" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M83,158L83,183L83,208" marker-end="url(#arrowhead829)" style="fill:none"></path><defs><marker id="arrowhead829" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M232.5,158L232.5,183L232.5,208" marker-end="url(#arrowhead830)" style="fill:none"></path><defs><marker id="arrowhead830" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="A" transform="translate(157.75,42)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM</div></foreignObject></g></g></g><g class="node cyan" id="B1" transform="translate(83,136)" style="opacity: 1;"><rect rx="0" ry="0" x="-44" y="-22" width="88" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-34,-12)"><foreignObject width="68" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">class type</div></foreignObject></g></g></g><g class="node cyan" id="B2" transform="translate(232.5,136)" style="opacity: 1;"><rect rx="0" ry="0" x="-50" y="-22" width="100" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-40,-12)"><foreignObject width="80" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">data model</div></foreignObject></g></g></g><g class="node cyan" id="C1" transform="translate(83,230)" style="opacity: 1;"><rect rx="0" ry="0" x="-63" y="-22" width="126" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-53,-12)"><foreignObject width="106" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">object instance</div></foreignObject></g></g></g><g class="node cyan" id="C2" transform="translate(232.5,230)" style="opacity: 1;"><rect rx="0" ry="0" x="-36.5" y="-22" width="73" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-26.5,-12)"><foreignObject width="53" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RDBMS</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  由于有几种可能的实现方案，我们将首先讨论每种方案的优缺点。</p>
<p>  首先，这里有一个图，展示了使用Delphi进行数据库访问的一些常见实现方案（它也代表了大多数其他语言或框架，包括c#或Java）。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-14" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 696 720" style="max-width:696px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-14 .node&gt;rect { ; }
#mermaid-diagram-14 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-14 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-14 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-14 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M85,76L85,137L85,186" marker-end="url(#arrowhead869)" style="fill:none"></path><defs><marker id="arrowhead869" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M238,76L238,137L238,186" marker-end="url(#arrowhead870)" style="fill:none"></path><defs><marker id="arrowhead870" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M238,230L238,291L238,352" marker-end="url(#arrowhead871)" style="fill:none"></path><defs><marker id="arrowhead871" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M375,76L375,137L375,186" marker-end="url(#arrowhead872)" style="fill:none"></path><defs><marker id="arrowhead872" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M375,230L375,291L375,352" marker-end="url(#arrowhead873)" style="fill:none"></path><defs><marker id="arrowhead873" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M495,76L495,137L495,186" marker-end="url(#arrowhead874)" style="fill:none"></path><defs><marker id="arrowhead874" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M619,88L619,137L619,186" marker-end="url(#arrowhead875)" style="fill:none"></path><defs><marker id="arrowhead875" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M495,230L495,291L540.566265060241,352" marker-end="url(#arrowhead876)" style="fill:none"></path><defs><marker id="arrowhead876" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M619,230L619,291L573.433734939759,352" marker-end="url(#arrowhead877)" style="fill:none"></path><defs><marker id="arrowhead877" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M557,396L557,445L557,494" marker-end="url(#arrowhead878)" style="fill:none"></path><defs><marker id="arrowhead878" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M557,538L557,587L557,636" marker-end="url(#arrowhead879)" style="fill:none"></path><defs><marker id="arrowhead879" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(85,137)" style="opacity: 1;"><g transform="translate(-15.5,-12)" class="label"><foreignObject width="31" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">RAD</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(238,137)" style="opacity: 1;"><g transform="translate(-51,-12)" class="label"><foreignObject width="102" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">code mapping</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(238,291)" style="opacity: 1;"><g transform="translate(-43.5,-24)" class="label"><foreignObject width="87" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Handwritten<br>SQL</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(375,137)" style="opacity: 1;"><g transform="translate(-27,-24)" class="label"><foreignObject width="54" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">MVC<br>binding</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(375,291)" style="opacity: 1;"><g transform="translate(-37,-24)" class="label"><foreignObject width="74" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Generated<br>SQL</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(495,137)" style="opacity: 1;"><g transform="translate(-44.5,-24)" class="label"><foreignObject width="89" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">MVC/MVVM<br>binding</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(619,137)" style="opacity: 1;"><g transform="translate(-27,-24)" class="label"><foreignObject width="54" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">MVC<br>binding</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(495,291)" style="opacity: 1;"><g transform="translate(-30,-36)" class="label"><foreignObject width="60" height="72"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Secure<br>protocol<br>REST</span></div></foreignObject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"></span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(557,445)" style="opacity: 1;"><g transform="translate(-39,-24)" class="label"><foreignObject width="78" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Persistence<br>layer</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(557,587)" style="opacity: 1;"><g transform="translate(-37,-24)" class="label"><foreignObject width="74" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">Generated<br>SQL</span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="A1" transform="translate(85,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-65" y="-22" width="130" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-55,-12)"><foreignObject width="110" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">UI Components</div></foreignObject></g></g></g><g class="node cyan" id="A2" transform="translate(85,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-44" y="-22" width="88" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-34,-12)"><foreignObject width="68" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">class type</div></foreignObject></g></g></g><g class="node cyan" id="B1" transform="translate(238,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-17.5" y="-22" width="35" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-7.5,-12)"><foreignObject width="15" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">UI</div></foreignObject></g></g></g><g class="node cyan" id="B2" transform="translate(238,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-59" y="-22" width="118" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-49,-12)"><foreignObject width="98" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Delphi classes</div></foreignObject></g></g></g><g class="node cyan" id="B3" transform="translate(238,374)" style="opacity: 1;"><rect rx="0" ry="0" x="-43" y="-22" width="86" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-33,-12)"><foreignObject width="66" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Database</div></foreignObject></g></g></g><g class="node cyan" id="C1" transform="translate(375,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-17.5" y="-22" width="35" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-7.5,-12)"><foreignObject width="15" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">UI</div></foreignObject></g></g></g><g class="node cyan" id="C2" transform="translate(375,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM</div></foreignObject></g></g></g><g class="node cyan" id="C3" transform="translate(375,374)" style="opacity: 1;"><rect rx="0" ry="0" x="-43" y="-22" width="86" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-33,-12)"><foreignObject width="66" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Database</div></foreignObject></g></g></g><g class="node cyan" id="D1" transform="translate(495,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-24" y="-22" width="48" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-14,-12)"><foreignObject width="28" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">UI 1</div></foreignObject></g></g></g><g class="node cyan" id="D2" transform="translate(495,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-37" y="-22" width="74" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-27,-12)"><foreignObject width="54" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client 1</div></foreignObject></g></g></g><g class="node cyan" id="E1" transform="translate(619,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-24.5" y="-34" width="49" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-14.5,-24)"><foreignObject width="29" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">UI 2<br>web</div></foreignObject></g></g></g><g class="node cyan" id="E2" transform="translate(619,208)" style="opacity: 1;"><rect rx="0" ry="0" x="-37" y="-22" width="74" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-27,-12)"><foreignObject width="54" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Client 2</div></foreignObject></g></g></g><g class="node cyan" id="D3" transform="translate(557,374)" style="opacity: 1;"><rect rx="0" ry="0" x="-32" y="-22" width="64" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-22,-12)"><foreignObject width="44" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Server</div></foreignObject></g></g></g><g class="node cyan" id="D4" transform="translate(557,516)" style="opacity: 1;"><rect rx="0" ry="0" x="-28" y="-22" width="56" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18,-12)"><foreignObject width="36" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ORM</div></foreignObject></g></g></g><g class="node cyan" id="D5" transform="translate(557,658)" style="opacity: 1;"><rect rx="0" ry="0" x="-38.5" y="-22" width="77" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-28.5,-12)"><foreignObject width="57" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Databse</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  下表对Delphi世界中的一些常见方案进行了非常有启发性的介绍，ORM只是其中一种不错的可选性。</p>
<table>
<thead>
<tr>
<th>方案</th>
<th>优点</th>
<th>缺点</th>
</tr>
</thead>
<tbody>
<tr>
<td>使用带有GUI组件的DB视图和表</td>
<td>SQL是一种功能强大的语言<br>可以使用高级DB工具（UML）和RAD方法</td>
<td>业务逻辑需要用存储过程来表述<br>SQL代码和存储过程将把你绑定到一个数据库引擎<br>客户端交互差<br>必须直接调用数据库生成报表<br>没有多层架构</td>
</tr>
<tr>
<td>用Delphi类映射数据库表或视图</td>
<td>可以在Delphi中使用详细的业务逻辑<br>与UI和数据分离</td>
<td>SQL代码必须手工编写，并与类同步<br>代码往往是重复的<br>SQL代码将你绑定到一个数据库引擎<br>从代码或通过数据库相关工具生成报表<br>难以实现真正的多层架构</td>
</tr>
<tr>
<td>使用ORM数据库</td>
<td>能在Delphi中使用非常详细的业务逻辑<br>SQL代码是由ORM生成的（通常情况下）<br>ORM将生成与DB引擎适配的SQL</td>
<td>设计时需要更多的抽象（没有RAD方法）<br>在某些情况下，可能导致从数据库检索的数据多于所需<br>还不是一个真正的多层架构，因为ORM只用于DB访问，业务逻辑需要创建独立的类</td>
</tr>
<tr>
<td>完整的多层架构</td>
<td>能在Delphi中使用非常详细的业务逻辑<br>SQL代码是由ORM生成的（通常情况下）<br>ORM将生成与DB引擎适配的SQL<br>服务只检索或处理所需要的数据<br>服务器可以创建被客户端视为数据库对象的对象视图，不管这些对象仅在内存中可用，还是Delphi中定义的一些业务逻辑<br>完整的多层架构</td>
<td>设计时需要更多的抽象（没有RAD方法）</td>
</tr>
</tbody>
</table>
<p>  您会发现我们的框架实现了一个客户端-服务端ORM，如果需要，可以将其缩小到独立模式，但是由于其独特的实现，它可以扩展到任何复杂的领域驱动设计。</p>
<p>  就我们所知，看看周围的每种语言和技术，几乎没有其他ORM支持这种面向本机客户端-服务端的方法。通常的实践是使用面向服务的架构（SOA）远程访问ORM。有些项目允许远程访问现有ORM，但它们是独立的项目。我们的mORMot从一开始就以RESTful客户端-服务端为导向，非常独特。</p>
<p>  如果您在多年前就进入了Delphi世界，那么您可能非常熟悉RAD方法。但是您可能还会发现，维护一个混合了UI组件、业务逻辑和数据库查询的应用程序是多么困难。今天的软件用户对软件可用性有一些巨大的人体工程学期望：仅带有表格和按钮的屏幕，映射数据库，并不一定有吸引力。使用mORMot的ORM/SOA方法将帮助您专注于您的业务和您的客户期望，让框架为您执行大多数模块集成。</p>
<h2 id="toc_7">2.7. NoSQL和对象文档映射（ODM）<a class="vnote-anchor" href="#toc_7" data-anchor-icon="#"></a></h2>
<p>  SQL是数据操作的事实标准。</p>
<ul>
<li>基于Schema；</li>
<li>基于关系；</li>
<li>ACID事务；</li>
<li>实践证明有效；</li>
<li>事实上的“标准”（每个DB都有自己的列类型系统）。</li>
</ul>
<p>  NoSQL是一种新的范例，在2009年初被命名为NoSQL（一些数据库引擎，如Lotus Domino，可能在几十年前就符合这个定义）：</p>
<ul>
<li>NoSQL代表“Not Only SQL”，比“no SQL”更贴切；</li>
<li>适用于网络和大数据（如亚马逊、谷歌、Facebook），如简单的复制和API；</li>
<li>不依赖标准（数据建模和查询）；</li>
<li>拥有许多不同的实现，涵盖任何数据使用，<a href="http://nosql-database.xn--org150-uv7imyt2wji449d7mqfrr">http://nosql-database.org列出了150多个引擎</a>。</li>
</ul>
<p>  我们可以确定NoSQL数据库的两个主要系列：</p>
<ul>
<li>面向图形的数据库；</li>
<li>面向聚合的数据库。</li>
</ul>
<p>  面向图形的数据库通过关系/关联存储数据：</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-15" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 553 580" style="max-width:553px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-15 .node&gt;rect { ; }
#mermaid-diagram-15 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-15 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-15 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-15 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M240.9018691588785,112L199,173L240.9018691588785,234" marker-end="url(#arrowhead908)" style="fill:none"></path><defs><marker id="arrowhead908" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M220.5,95.43915343915344L83.5,173L83.5,280L83.5,387L215.5,461.73015873015873" marker-end="url(#arrowhead909)" style="fill:none"></path><defs><marker id="arrowhead909" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M240.9018691588785,326L199,387L240.9018691588785,448" marker-end="url(#arrowhead910)" style="fill:none"></path><defs><marker id="arrowhead910" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M304.0981308411215,234L346,173L304.0981308411215,112" marker-end="url(#arrowhead911)" style="fill:none"></path><defs><marker id="arrowhead911" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M305.81775700934577,448L350,387L305.81775700934577,326" marker-end="url(#arrowhead912)" style="fill:none"></path><defs><marker id="arrowhead912" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M329.5,461.0324324324324L457.5,387L457.5,280L457.5,173L324.5,96.07567567567568" marker-end="url(#arrowhead913)" style="fill:none"></path><defs><marker id="arrowhead913" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(199,173)" style="opacity: 1;"><g transform="translate(-63.5,-36)" class="label"><foreignObject width="127" height="72"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">ID: 100<br>Label: knows<br>Since: 2001/10/03</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(83.5,280)" style="opacity: 1;"><g transform="translate(-63.5,-36)" class="label"><foreignObject width="127" height="72"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">ID: 102<br>Label: is_member<br>Since: 2005/07/01</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(199,387)" style="opacity: 1;"><g transform="translate(-63.5,-36)" class="label"><foreignObject width="127" height="72"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">ID: 105<br>Label: is_member<br>Since: 2011/02/14</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(346,173)" style="opacity: 1;"><g transform="translate(-63.5,-36)" class="label"><foreignObject width="127" height="72"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">ID: 101<br>Label: knows<br>Since: 2001/10/04</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(350,387)" style="opacity: 1;"><g transform="translate(-55.5,-24)" class="label"><foreignObject width="111" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">ID: 104<br>Label: members</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(457.5,280)" style="opacity: 1;"><g transform="translate(-55.5,-24)" class="label"><foreignObject width="111" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">D: 103<br>Label: members</span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="ID1" transform="translate(272.5,66)" style="opacity: 1;"><rect rx="0" ry="0" x="-52" y="-46" width="104" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-42,-36)"><foreignObject width="84" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ID: 1<br>Name: Alice<br>Age: 18</div></foreignObject></g></g></g><g class="node cyan" id="ID2" transform="translate(272.5,280)" style="opacity: 1;"><rect rx="0" ry="0" x="-49" y="-46" width="98" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-39,-36)"><foreignObject width="78" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ID: 2<br>Name: Bob<br>Age: 22</div></foreignObject></g></g></g><g class="node cyan" id="ID3" transform="translate(272.5,494)" style="opacity: 1;"><rect rx="0" ry="0" x="-57" y="-46" width="114" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-47,-36)"><foreignObject width="94" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">ID: 3<br>Name: Group<br>Name: Chess</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  这种数据库是非常有用的，例如，对于开发任何“社交”软件，它会通过每个节点之间的关系来评估其数据。这样的数据模型与关系模型不兼容，像Neo4j这样的NoSQL引擎在本地处理这类数据。按照设计，面向图形的数据库符合ACID。</p>
<p>  主流的NoSQL数据库系列是面向聚合的数据库。对于聚合，我们的定义与下面用于领域驱动设计的定义相同。它是作为一个单元进行交互的数据集合，构成了给定模型中ACID操作的边界。</p>
<p>  事实上，面向聚合的数据库可以指定为三种主要的实现/查询模式:</p>
<ul>
<li>基于文档的（如MongoDB、CouchDB、RavenDB）；</li>
<li>键/值（例如Redis、Riak、Voldemort）；</li>
<li>列族（如Cassandra、HiBase）。</li>
</ul>
<p>  他们中的一些可以无模式（即数据布局是不固定的，并且可以动态进化没有重新索引整个数据库），但是基于列驱动模式，甚至仅能存储普通的BLOB数据（这是键/值引擎的目的，关注存储速度和依赖客户端处理数据)。</p>
<p>  简言之，RDBMS按表存储数据，需要连接引用来获得聚合信息：</p>
<div class="plantuml-diagram"><!--?xml version="1.0" encoding="UTF-8" standalone="no"?--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentscripttype="application/ecmascript" contentstyletype="text/css" height="241px" preserveAspectRatio="none" style="width:311px;height:241px;" version="1.1" viewBox="0 0 311 241" width="311px" zoomAndPan="magnify" class="view-svg"><defs><filter height="300%" id="f18qrtwgpl2gtc" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"></feGaussianBlur><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"></feColorMatrix><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"></feOffset><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"></feBlend></filter></defs><g><ellipse cx="70.6668" cy="60.3335" fill="#FEFECE" filter="url(#f18qrtwgpl2gtc)" rx="64.6668" ry="52.3335" style="stroke: #A80036; stroke-width: 1.5;"></ellipse><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="13" x="64.1668" y="26.8949">ID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="18.996" x2="122.3376" y1="29.9711" y2="29.9711"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="42" x="49.6668" y="50.0151">UserID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="7.1242" x2="134.2094" y1="57.0912" y2="57.0912"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="41" x="50.1668" y="77.1352">Phone</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="14.1234" x2="127.2102" y1="84.2113" y2="84.2113"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="34" x="53.6668" y="104.2553">Email</text><ellipse cx="235.6245" cy="60.6996" fill="#FEFECE" filter="url(#f18qrtwgpl2gtc)" rx="65.1245" ry="52.6996" style="stroke: #A80036; stroke-width: 1.5;"></ellipse><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="13" x="229.1245" y="26.8929">ID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="183.7186" x2="287.5304" y1="29.9691" y2="29.9691"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="42" x="214.6245" y="50.013">UserID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="171.653" x2="299.5959" y1="57.0892" y2="57.0892"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="34" x="218.6245" y="77.1331">Level</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="178.3394" x2="292.9095" y1="84.2093" y2="84.2093"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="40" x="215.6245" y="104.2533">Group</text><ellipse cx="152.3731" cy="201.7463" fill="#FEFECE" filter="url(#f18qrtwgpl2gtc)" rx="45.8731" ry="28.7463" style="stroke: #A80036; stroke-width: 1.5;"></ellipse><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="13" x="145.8731" y="191.9177">ID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="108.7835" x2="195.9627" y1="194.9939" y2="194.9939"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="65" x="119.8731" y="215.0379">UserName</text><!--MD5=[a1d4b06a7f08f673ba6551d9d9d7a186]
link UC1 to UC3--><path d="M98.0329,108.172 C110.043,128.53 123.787,151.8276 134.464,169.9267 " fill="none" id="UC1->UC3" style="stroke: #A80036; stroke-width: 1.0;"></path><polygon fill="#A80036" points="137.11,174.4113,135.9814,164.6273,134.5691,170.105,129.0914,168.6927,137.11,174.4113" style="stroke: #A80036; stroke-width: 1.0;"></polygon><!--MD5=[594891eb4838d876d29f7ff5a36f2080]
link UC2 to UC3--><path d="M207.631,108.172 C195.475,128.53 181.563,151.8276 170.756,169.9267 " fill="none" id="UC2->UC3" style="stroke: #A80036; stroke-width: 1.0;"></path><polygon fill="#A80036" points="168.078,174.4113,176.1265,168.7349,170.6414,170.1184,169.2579,164.6334,168.078,174.4113" style="stroke: #A80036; stroke-width: 1.0;"></polygon><!--MD5=[5cd727f337e53b175a906f6ac9597927]
@startuml
usecase UC1 as "ID
- -
UserID
- -
Phone
- -
Email"

usecase UC2 as "ID
- -
UserID
- -
Level
- -
Group"

usecase UC3 as "ID
- -
UserName"

(UC1) - ->(UC3)
(UC2) - ->(UC3)
@enduml

PlantUML version 1.2019.12(Sun Nov 03 18:24:54 CST 2019)
(GPL source distribution)
Java Runtime: OpenJDK Runtime Environment
JVM: OpenJDK 64-Bit Server VM
Java Version: 13.0.1+9
Operating System: Windows 10
Default Encoding: GBK
Language: zh
Country: CN
--></g></svg></div>
<p>  而NoSQL将其聚合存储为文档：所有数据都嵌入其中。</p>
<div class="plantuml-diagram"><!--?xml version="1.0" encoding="UTF-8" standalone="no"?--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentscripttype="application/ecmascript" contentstyletype="text/css" height="183px" preserveAspectRatio="none" style="width:223px;height:183px;" version="1.1" viewBox="0 0 223 183" width="223px" zoomAndPan="magnify" class="view-svg"><defs><filter height="300%" id="f1fsbqaymtj3ja" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"></feGaussianBlur><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"></feColorMatrix><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"></feOffset><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"></feBlend></filter></defs><g><ellipse cx="109.5561" cy="89.6449" fill="#FEFECE" filter="url(#f1fsbqaymtj3ja)" rx="102.5561" ry="82.6449" style="stroke: #A80036; stroke-width: 1.5;"></ellipse><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="13" x="103.0561" y="25.7901">ID</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="41.0629" x2="178.0494" y1="28.8662" y2="28.8662"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="65" x="77.0561" y="48.9102">UserName</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="16.8907" x2="202.2216" y1="55.9863" y2="55.9863"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="94" x="62.5561" y="76.0303">Contact.Phone</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="8.3215" x2="210.7908" y1="83.1065" y2="83.1065"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="87" x="66.0561" y="103.1504">Contact.Email</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="11.2311" x2="207.8811" y1="110.2266" y2="110.2266"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="83" x="68.0561" y="130.2705">Access.Level</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="26.8077" x2="192.3045" y1="137.3467" y2="137.3467"></line><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="89" x="65.0561" y="157.3906">Access.Group</text><!--MD5=[35bd771e75b12b908abe0761a2ad28eb]
@startuml
usecase UC1 as "ID
- -
UserName
- -
Contact.Phone
- -
Contact.Email
- -
Access.Level
- -
Access.Group"

@enduml

PlantUML version 1.2019.12(Sun Nov 03 18:24:54 CST 2019)
(GPL source distribution)
Java Runtime: OpenJDK Runtime Environment
JVM: OpenJDK 64-Bit Server VM
Java Version: 13.0.1+9
Operating System: Windows 10
Default Encoding: GBK
Language: zh
Country: CN
--></g></svg></div>
<p>  这可以表示为以下JSON数据：</p>
<pre><code class="lang-json hljs">{
  <span class="hljs-attr">"ID"</span>: <span class="hljs-number">1234</span>,
  <span class="hljs-attr">"UserName"</span>: <span class="hljs-string">"John Smith"</span>,
  <span class="hljs-attr">"Contact"</span>: {
               <span class="hljs-attr">"Phone"</span>: <span class="hljs-string">"123-456-789"</span>,
               <span class="hljs-attr">"Email"</span>: <span class="hljs-string">"xyz@abc.com"</span>
             },
  <span class="hljs-attr">"Access"</span>: {
              <span class="hljs-attr">"Level"</span>: <span class="hljs-number">5</span>,
              <span class="hljs-attr">"Group"</span>: <span class="hljs-string">"dev"</span>
            }
}
</code></pre>
<p>  这样的文档将直接适合对象编程模型，而不需要考虑关联查询和数据库装配。</p>
<p>  因此，我们可以讨论两种数据模型：</p>
<ul>
<li>具有高度结构化的表组织、严格定义的数据格式和记录结构的关系数据模型;</li>
<li>文档数据模型是具有任意嵌套数据格式和不同“记录”格式的复杂文档的集合。</li>
</ul>
<p>  关系模型的特点是数据的规范化，即有效组织关系数据库的字段和表，以减少冗余。</p>
<p>  另一方面，文档模型的特点是数据的反规范化，通过添加冗余数据或对数据进行分组来优化数据库的读取性能。它还支持服务器的水平伸缩，因为数据可以很容易地在多个服务器之间进行平衡，而没有执行远程连接的速度损失。</p>
<p>  在使用NoSQL时，主要困难之一是如何定义反规范化数据，以及何时以规范化格式存储数据。</p>
<p>  一个好习惯是根据需要经常执行的查询为数据建模。例如，您可能会嵌入子文档，这些子文档很可能是应用程序在大多数情况下请求的。大多数NoSQL引擎都具有投影机制，该机制允许您仅返回查询所需的字段，如果您此时不需要这些字段，则将子文档保留在服务器上。而不频繁的查询可以在单独的集合上执行，如使用信息查合并询。</p>
<p>  由于NoSQL数据库比它们的关系数据库祖先拥有更少的硬而快速的规则，因此您更有可能根据您的期望优化您的模型。在实践中，与使用RDBMS相比，您可能花费更少的时间考虑“如何”存储数据，并且如果需要的话，以后仍然能够规范化信息。只要遵循客户端应用程序处理整个数据的一致性（例如通过一个ORM）的规则，NoSQL引擎就不会担心冗余信息。</p>
<p>  正如您可能已经注意到的，这个文档数据模型比传统的关系模式更接近OOP范式。以至于在采用NoSQL的同时出现了一个新的框架家族，名为对象文档映射(Object Document Mapping, ODM)，对应RDBMS就是对象关系映射(Object- relational Mapping, ORM)。</p>
<p>  简而言之，这两种方法都有好处，需要加以权衡。</p>
<table>
<thead>
<tr>
<th>SQL</th>
<th>NoSQL</th>
</tr>
</thead>
<tbody>
<tr>
<td>无处不在的SQL</td>
<td>映射OOP和复杂类型（例如数组或嵌套文档）</td>
</tr>
<tr>
<td>垂直扩展容易</td>
<td>解耦数据：水平扩张</td>
</tr>
<tr>
<td>数据大小（避免重复且没有schema）</td>
<td>Schema-less：清晰进化</td>
</tr>
<tr>
<td>数据存储一次，一致性好</td>
<td>版本管理（例如CouchDB）</td>
</tr>
<tr>
<td>复杂的ACID语句</td>
<td>图形存储（如Redis）</td>
</tr>
<tr>
<td>聚合函数（依赖）</td>
<td>Map/Reduce或聚合函数（如从MongoDB 2.2开始）</td>
</tr>
</tbody>
</table>
<p>  <strong><em>译者注：Map/Reduce是一个编程模型,处理产生大数据集的相关实现.用户指定一个map函数处理一个key/value对,从而产生中间的key/value对集.然后再指定一个reduce函数合并所有的具有相同中间key的中间value</em></strong></p>
<p>  使用mORMot，在服务器端初始化数据时，只需一行代码，就可以从传统的SQL引擎切换到时髦的MongoDB服务器。对于要求较高的客户，您可以在任何时候从ORM切换到ODM，包括运行时。</p>
<h2 id="toc_8">2.8. 领域驱动设计<a class="vnote-anchor" href="#toc_8" data-anchor-icon="#"></a></h2>
<h3 id="toc_9">2.8.1. 定义<a class="vnote-anchor" href="#toc_9" data-anchor-icon="#"></a></h3>
<p>  <a href="http://domaindrivendesign.xn--org-3h9dx1n43a89vvm5frbyajia345jn2e">http://domaindrivendesign.org给出了领域驱动设计</a>（DDD）的某种“官方”定义：</p>
<p>  在过去的一二十年中，一种哲学作为一种潜流在对象社区中发展起来。领域驱动设计的前提是双重的：</p>
<ul>
<li>对于大多数软件项目，主要关注点应该是领域和领域逻辑；</li>
<li>复杂的领域设计应该基于模型。</li>
</ul>
<p>  领域驱动的设计不是一种技术或方法。它是一种思维方式和一组优先级，旨在加速处理复杂领域的软件项目。</p>
<p>  当然，这个特定的体系结构可以根据每个项目的需要进行定制。我们只是建议遵循一个基线，根据他们的需要和需求做好修改或调整服务。</p>
<h3 id="toc_10">2.8.2. 模式<a class="vnote-anchor" href="#toc_10" data-anchor-icon="#"></a></h3>
<p>对于其他类型的多层架构，DDD引入了一些限制性的模式，使设计更加简洁：</p>
<ul>
<li>专注于某一领域，即某一种特定的知识；</li>
<li>在该领域中定义有界上下文；</li>
<li>创建域的演进模型，供应用程序使用；</li>
<li>识别某些类型的对象，值对象或实体对象/聚合;</li>
<li>在生成的模型和代码中使用普遍存在的语言；</li>
<li>将域与其他类型的关注点隔离（如不应从域层调用持久性，即域不应受技术考虑的影响，而应依赖于<em>Factory</em>和<em>Repository</em>模式）；</li>
<li>将域发布为定义良好的解耦服务；</li>
<li>将域服务与现有应用程序或遗留代码集成。</li>
</ul>
<p>  下图是它们之间的模式呈现及关系映射。<br>
  它的灵感来自埃里克·埃文斯(Eric Evans)的《领域驱动的设计》， Addison-Wesley, 2004年出版的一本书（该书更新后提出了此后出现的一些观点）。</p>
<div class="mermaid-diagram"><svg id="mermaid-diagram-16" xmlns="http://www.w3.org/2000/svg" height="100%" viewBox="0 0 1099.75 554" style="max-width:1099.75px;"><style type="text/css" title="mermaid-svg-internal-css">/*  */
#mermaid-diagram-16 .node&gt;rect { ; }
#mermaid-diagram-16 .node text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-16 .edgeLabel text  { fill:#000; stroke:none; font-weight:300; font-family:"Helvetica Neue",Helvetica,Arial,sans-serf; font-size:14px; }
#mermaid-diagram-16 .cluster rect  { rx:4px; fill: rgb(255, 255, 222); rx: 4px; stroke: rgb(170, 170, 51); stroke-width: 1px; }
#mermaid-diagram-16 .cyan&gt;rect, .cyan&gt;polygon, .cyan&gt;circle, .cyan&gt;ellipse { fill:#9ff;  stroke:#fff; }
/*  */
</style><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M476.5,64.48608137044968L68.5,137L68.5,198" marker-end="url(#arrowhead959)" style="fill:none"></path><defs><marker id="arrowhead959" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M476.5,68.99846860643186L209,137L209,198" marker-end="url(#arrowhead960)" style="fill:none"></path><defs><marker id="arrowhead960" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M476.5,78.98469387755102L339.5,137L339.5,210" marker-end="url(#arrowhead961)" style="fill:none"></path><defs><marker id="arrowhead961" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M506.00602409638554,88L463.5,137L463.5,210" marker-end="url(#arrowhead962)" style="fill:none"></path><defs><marker id="arrowhead962" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M564.8915662650602,88L607.25,137L607.25,210" marker-end="url(#arrowhead963)" style="fill:none"></path><defs><marker id="arrowhead963" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M594.5,74.13155190133608L778.75,137L778.75,186" marker-end="url(#arrowhead964)" style="fill:none"></path><defs><marker id="arrowhead964" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M594.5,66.5806037251124L924.75,137L924.75,210" marker-end="url(#arrowhead965)" style="fill:none"></path><defs><marker id="arrowhead965" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M594.5,63.84816490698844L1032.75,137L1032.75,210" marker-end="url(#arrowhead966)" style="fill:none"></path><defs><marker id="arrowhead966" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M428.644578313253,254L332,315L375.271186440678,352" marker-end="url(#arrowhead967)" style="fill:none"></path><defs><marker id="arrowhead967" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M571.5993975903615,254L472.75,315L427.7542372881356,352" marker-end="url(#arrowhead968)" style="fill:none"></path><defs><marker id="arrowhead968" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M401,396L401,433L440.1949152542373,470" marker-end="url(#arrowhead969)" style="fill:none"></path><defs><marker id="arrowhead969" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M451.5,386.1985670419652L645.25,433L668.2966101694915,470" marker-end="url(#arrowhead970)" style="fill:none"></path><defs><marker id="arrowhead970" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M492.9879518072289,254L574.75,315L574.75,374L574.75,433L504.9830508474576,470" marker-end="url(#arrowhead971)" style="fill:none"></path><defs><marker id="arrowhead971" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M636.406626506024,254L717.25,315L717.25,374L717.25,433L695.1440677966102,470" marker-end="url(#arrowhead972)" style="fill:none"></path><defs><marker id="arrowhead972" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="translate(68.5,137)" style="opacity: 1;"><g transform="translate(-39.5,-24)" class="label"><foreignObject width="79" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">define<br>model with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(209,137)" style="opacity: 1;"><g transform="translate(-38,-24)" class="label"><foreignObject width="76" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">identify<br>scope with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(339.5,137)" style="opacity: 1;"><g transform="translate(-39.5,-24)" class="label"><foreignObject width="79" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">process<br>model with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(463.5,137)" style="opacity: 1;"><g transform="translate(-39.5,-24)" class="label"><foreignObject width="79" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">express<br>model with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(607.25,137)" style="opacity: 1;"><g transform="translate(-39.5,-24)" class="label"><foreignObject width="79" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">express<br>model with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(778.75,137)" style="opacity: 1;"><g transform="translate(-44,-24)" class="label"><foreignObject width="88" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">isolate<br>domain with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(924.75,137)" style="opacity: 1;"><g transform="translate(-46.5,-24)" class="label"><foreignObject width="93" height="48"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">express state<br>changes with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(1032.75,137)" style="opacity: 1;"><g transform="translate(-27,-12)" class="label"><foreignObject width="54" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">exclude</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(332,315)" style="opacity: 1;"><g transform="translate(-59,-12)" class="label"><foreignObject width="118" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">encapsulate with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(472.75,315)" style="opacity: 1;"><g transform="translate(-59,-12)" class="label"><foreignObject width="118" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">encapsulate with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(401,433)" style="opacity: 1;"><g transform="translate(-39.5,-12)" class="label"><foreignObject width="79" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">access with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(645.25,433)" style="opacity: 1;"><g transform="translate(-50.5,-12)" class="label"><foreignObject width="101" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">nstantiated by</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(574.75,374)" style="opacity: 1;"><g transform="translate(-39.5,-12)" class="label"><foreignObject width="79" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">access with</span></div></foreignObject></g></g><g class="edgeLabel" transform="translate(717.25,374)" style="opacity: 1;"><g transform="translate(-52.5,-12)" class="label"><foreignObject width="105" height="24"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span class="edgeLabel">instantiated by</span></div></foreignObject></g></g></g><g class="nodes"><g class="node cyan" id="A" transform="translate(535.5,54)" style="opacity: 1;"><rect rx="0" ry="0" x="-59" y="-34" width="118" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-49,-24)"><foreignObject width="98" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Model-Driven<br>Design</div></foreignObject></g></g></g><g class="node cyan" id="B1" transform="translate(68.5,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-48.5" y="-34" width="97" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-38.5,-24)"><foreignObject width="77" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Ubiquitous<br>Language</div></foreignObject></g></g></g><g class="node cyan" id="B2" transform="translate(209,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-42" y="-34" width="84" height="68"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-32,-24)"><foreignObject width="64" height="48"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Bounded<br>Contents</div></foreignObject></g></g></g><g class="node cyan" id="B3" transform="translate(339.5,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-38.5" y="-22" width="77" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-28.5,-12)"><foreignObject width="57" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Services</div></foreignObject></g></g></g><g class="node cyan" id="B4" transform="translate(463.5,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-35.5" y="-22" width="71" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-25.5,-12)"><foreignObject width="51" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Entities</div></foreignObject></g></g></g><g class="node cyan" id="B5" transform="translate(607.25,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-58" y="-22" width="116" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-48,-12)"><foreignObject width="96" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Value Objects</div></foreignObject></g></g></g><g class="node cyan" id="B6" transform="translate(778.75,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-63.5" y="-46" width="127" height="92"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-53.5,-36)"><foreignObject width="107" height="72"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Clean/Layered/<br>Hexagonal<br>Architecture</div></foreignObject></g></g></g><g class="node cyan" id="B7" transform="translate(924.75,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-32.5" y="-22" width="65" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-22.5,-12)"><foreignObject width="45" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Events</div></foreignObject></g></g></g><g class="node cyan" id="B8" transform="translate(1032.75,232)" style="opacity: 1;"><rect rx="0" ry="0" x="-25.5" y="-22" width="51" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-15.5,-12)"><foreignObject width="31" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">RAD</div></foreignObject></g></g></g><g class="node cyan" id="C" transform="translate(401,374)" style="opacity: 1;"><rect rx="0" ry="0" x="-50.5" y="-22" width="101" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-40.5,-12)"><foreignObject width="81" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Aggregates</div></foreignObject></g></g></g><g class="node cyan" id="D1" transform="translate(463.5,492)" style="opacity: 1;"><rect rx="0" ry="0" x="-53" y="-22" width="106" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-43,-12)"><foreignObject width="86" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Repositories</div></foreignObject></g></g></g><g class="node cyan" id="D2" transform="translate(682,492)" style="opacity: 1;"><rect rx="0" ry="0" x="-41" y="-22" width="82" height="44"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-31,-12)"><foreignObject width="62" height="24"><div style="display: inline-block; white-space: nowrap;" xmlns="http://www.w3.org/1999/xhtml">Factories</div></foreignObject></g></g></g></g></g></g></svg></div>
<p>  您可能已经遇到或使用过现有的许多模式。DDD的独特之处在于，由于几十年的商业软件试验，这些模式已经围绕一些清晰的概念进行了组织。</p>
<h3 id="toc_11">2.8.3. DDD适合您吗<a class="vnote-anchor" href="#toc_11" data-anchor-icon="#"></a></h3>
<p>  领域驱动设计并不能在任何地方、任何情况下使用。</p>
<p>  首先，使用DDD的前提是：</p>
<ul>
<li>识别和界定领域（如您的业务目标的识别应该是明确的）；</li>
<li>您必须能够访问领域专家，以敏捷迭代的方式建立创造性的协作；</li>
<li>技术熟练的团队，能够编写清晰的代码，因为DDD更多的是关于代码的表达能力，而不是技术，所以对于年轻的开发人员来说，它可能显得不那么“时髦”；</li>
<li>您希望您的内部团队积累领域的知识，因此，外包可能局限于应用程序，而不是核心领域。</li>
</ul>
<p>  然后检查DDD是否值得，即：</p>
<ul>
<li>它能帮助你解决你想要解决的问题；</li>
<li>它符合您的战略目标：DDD将用于能获得业务资金的地方，并使您从竞争对手中脱颖而出；</li>
<li>您需要思路清晰，需要解决内部的复杂性，例如，对许多规则建模（您不会使用DDD来构建简单的应用程序，否则RAD可能就足够了）；</li>
<li>你的企业正在探索：你的目标已经确定，但你不知道如何实现它；</li>
<li>不要贪多，选择一两个目标。</li>
</ul>
<h3 id="toc_12">2.8.4. DDD简介<a class="vnote-anchor" href="#toc_12" data-anchor-icon="#"></a></h3>
<p>  现在也许DDD听起来很吸引你。在这种情况下，我们的mORMot框架将提供实现它所需的所有模块，重点放在您的领域上，让库完成所有需要的基础工作。<br>
  如果您确定现在不使用DDD，您将始终能在mORMot找到您需要的工具，准备在需要时切换到DDD。</p>
<p>  遗留代码和现有项目将受益于DDD模式。在使用DDD技术重构和收紧代码中最有价值的部分是所谓的缝合和隔离核心领域。使用DDD模式重写整个现有软件不是必须的：一旦您确定了业务策略的核心所在，就可以在这个领域逐步引入DDD。然后，根据持续的反馈，您将改进您的代码，添加回归测试，并将您的领域代码与最终用户代码隔离开来。</p>
<p>  有关DDD的技术介绍以及mORMot如何帮助您实现此设计，详见<a href="">领域驱动设计</a>。</p>
<p>  使用mORMot，您的软件解决方案永远不会陷入死胡同。您将能够始终适应客户的需要，并最大化您的投资回报率。</p>

    </div>
</div>
</div>

<div id="container-floating" style="display:none;" class="d-none d-md-block d-xl-block">
    <div id="floating-button" onclick="toggleMore()">
        <p id="floating-more" class="more">&gt;</p>
    </div>
</div>

<!--
<div class="footer" id="vnote-footer">
    <p>Generated by <em><a href="https://tamlok.github.io/vnote/">VNote</a></em>.</p>
</div>
-->
</body>
</html>
